1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

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>
(cherry picked from commit 4dc67f6ba28f888328a2568bbcacf49e552650da)
This commit is contained in:
ChristopherHX 2024-12-24 22:33:13 +01:00 committed by Earl Warren
parent 96891ab314
commit 393c8b04f7
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -340,7 +340,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(),