File tree Expand file tree Collapse file tree
builder/image/slugbuilder/builder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,13 +84,24 @@ if [[ -n "$BUILDPACK_URL" ]]; then
8484 rm -fr " $buildpack "
8585
8686 url=${BUILDPACK_URL%#* }
87- branch =${BUILDPACK_URL#*# }
87+ committish =${BUILDPACK_URL#*# }
8888
89- if [ " $branch " == " $url " ]; then
90- branch =" master"
89+ if [ " $committish " == " $url " ]; then
90+ committish =" master"
9191 fi
9292
93- git clone --quiet --branch " $branch " --depth=1 " $url " " $buildpack "
93+ set +e
94+ git clone --quiet --branch " $committish " --depth=1 " $url " " $buildpack "
95+ SHALLOW_CLONED=$?
96+ set -e
97+ if [ $SHALLOW_CLONED -ne 0 ]; then
98+ # if the shallow clone failed partway through, clean up and try a full clone
99+ rm -rf " $buildpack "
100+ git clone --quiet " $url " " $buildpack "
101+ pushd " $buildpack " & > /dev/null
102+ git checkout --quiet " $committish "
103+ popd & > /dev/null
104+ fi
94105
95106 selected_buildpack=" $buildpack "
96107 buildpack_name=$( $buildpack /bin/detect " $build_root " ) && selected_buildpack=$buildpack
You can’t perform that action at this time.
0 commit comments