fix: dereference annotated tags

refs/heads/master cannot be updated to an annotated tag per se; the rev
given must first be resolved to a commit. ^{commit} recursively
dereferences the rev until a commit is found.

Resolves #6737 and test failure:

    # bats --filter annotated-tag tests/unit/git_3.bats
    git_3.bats
     ✗ (git) git:sync existing [--no-build annotated-tag]
       fatal: update_ref failed for ref 'refs/heads/master': cannot update ref 'refs/heads/master': trying to write non-commit object 6399bed673f513332f3d5d99e777e0262f42404c to branch 'refs/heads/master'
This commit is contained in:
Andrew Kvalheim
2024-03-18 17:30:19 -07:00
parent df8dd766b6
commit f64cf3bdfa
2 changed files with 25 additions and 1 deletions

View File

@@ -457,7 +457,7 @@ fn-git-fetch() {
GIT_TERMINAL_PROMPT=0 fn-git-cmd "$APP_ROOT" fetch --update-head-ok remote "$DOKKU_DEPLOY_BRANCH"
else
GIT_TERMINAL_PROMPT=0 fn-git-cmd "$APP_ROOT" fetch --update-head-ok remote
fn-git-cmd "$APP_ROOT" update-ref "refs/heads/$DOKKU_DEPLOY_BRANCH" "$GIT_REF"
fn-git-cmd "$APP_ROOT" update-ref "refs/heads/$DOKKU_DEPLOY_BRANCH" "$GIT_REF^{commit}"
fi
fn-git-cmd "$APP_ROOT" config --add core.bare true