From b4ef6fb482e19c439c01ec935689bdbf498aa3ce Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Tue, 24 Dec 2024 22:33:13 +0100 Subject: [PATCH] fix: short sha has at least four digits (#2540) Currently it is not very unlikly to have a false match for tag `0` with sha `0XXXXXXXXXXXXXXXXXXXXXXX`, 1 to 16 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/common/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/common/git/git.go b/pkg/common/git/git.go index 706f9ca..3c5af7b 100644 --- a/pkg/common/git/git.go +++ b/pkg/common/git/git.go @@ -330,7 +330,7 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) common.Executor { logger.Errorf("Unable to resolve %s: %v", input.Ref, err) } - if hash.String() != input.Ref && strings.HasPrefix(hash.String(), input.Ref) { + if hash.String() != input.Ref && len(input.Ref) >= 4 && strings.HasPrefix(hash.String(), input.Ref) { return &Error{ err: ErrShortRef, commit: hash.String(),