From 978dfdf6152a9896dddce8ce0c4615c66efecf2c Mon Sep 17 00:00:00 2001 From: ChristopherHX Date: Sun, 24 Nov 2024 00:11:50 +0100 Subject: [PATCH] fix: short sha has at least four digits Currently it is not very unlikly to have a false match for tag `0` with sha `0XXXXXXXXXXXXXXXXXXXXXXX`, 1 to 16 --- 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 706f9ca5802..3c5af7b3f5c 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(),