From 4f883e97075c26cbf26e568d70e4920757e0ce60 Mon Sep 17 00:00:00 2001 From: earl-warren Date: Thu, 7 Aug 2025 21:04:09 +0000 Subject: [PATCH] fix: short sha has at least four digits (#820) Refs https://github.com/nektos/act/pull/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) - bug fixes - [PR](https://code.forgejo.org/forgejo/runner/pulls/820): fix: short sha has at least four digits Co-authored-by: ChristopherHX Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/820 Reviewed-by: Gusted --- act/common/git/git.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/act/common/git/git.go b/act/common/git/git.go index 1748e797..bffe4feb 100644 --- a/act/common/git/git.go +++ b/act/common/git/git.go @@ -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(),