From f0fd0af5ce0f924e45c88aed4434ad5821da7b0d Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Wed, 8 Sep 2021 18:47:12 +0200 Subject: [PATCH] Refresh hash after pull for branch refs (#791) * Refresh hash after pull for branch refs * Bump Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/common/git.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/common/git.go b/pkg/common/git.go index c87906a..b1e1f54 100644 --- a/pkg/common/git.go +++ b/pkg/common/git.go @@ -376,6 +376,13 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor { } logger.Debugf("Cloned %s to %s", input.URL, input.Dir) + if hash.String() != input.Ref && refType == "branch" { + logger.Debugf("Provided ref is not a sha. Updating branch ref after pull") + if hash, err = r.ResolveRevision(rev); err != nil { + logger.Errorf("Unable to resolve %s: %v", input.Ref, err) + return err + } + } if err = w.Checkout(&git.CheckoutOptions{ Hash: *hash, Force: true,