refactor: properly handle commits and branches
- if it is a commit, we must clone and checkout. `clone --branch` only works for tags and branches - set the branch as the deploy-branch if detected
This commit is contained in:
1 parent
6dc55624bd
commit
dbd48356f5
1 file changed
+18
-5
@@ -207,12 +207,25 @@ fn-git-clone() {
|
|||||||
|
|
||||||
dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
|
dokku_log_info1_quiet "Cloning $APP from $GIT_REMOTE#$GIT_REF"
|
||||||
trap 'rm -rf $APP_CLONE_ROOT > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf $APP_CLONE_ROOT > /dev/null' RETURN INT TERM EXIT
|
||||||
git clone --depth 1 -n -qq --branch "$GIT_REF" "$GIT_REMOTE" "$APP_CLONE_ROOT"
|
|
||||||
|
|
||||||
if [[ "$GIT_REF" != "master" ]]; then
|
is_ref=true
|
||||||
pushd "$APP" > /dev/null
|
git clone --depth 1 -n -qq --branch "$GIT_REF" "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null && is_ref=false
|
||||||
git checkout -qq -b master
|
rm -rf "$APP_CLONE_ROOT"
|
||||||
popd > /dev/null
|
|
||||||
|
if [[ "$is_ref" == "true" ]]; then
|
||||||
|
git clone -n -qq "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null
|
||||||
|
git -C "$APP_CLONE_ROOT" checkout -qq "$GIT_REF"
|
||||||
|
else
|
||||||
|
git clone -n -qq --branch "$GIT_REF" "$GIT_REMOTE" "$APP_CLONE_ROOT" 2>/dev/null
|
||||||
|
if git -C "$APP_CLONE_ROOT" show-ref --verify "refs/heads/$GIT_REF" >/dev/null 2>&1; then
|
||||||
|
dokku_log_verbose "Detected branch, setting deploy-branch to $GIT_REF"
|
||||||
|
fn-plugin-property-write "git" "$APP" "deploy-branch" "$GIT_REF"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||||
|
if [[ "$GIT_REF" != "$DOKKU_DEPLOY_BRANCH" ]]; then
|
||||||
|
git -C "$APP_CLONE_ROOT" checkout -qq -b "$DOKKU_DEPLOY_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rsync -a "$APP_CLONE_ROOT/.git/" "$APP_ROOT"
|
rsync -a "$APP_CLONE_ROOT/.git/" "$APP_ROOT"
|
||||||
|
|||||||
Reference in new issue
Block a user