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

enable to resolve commit hash in uses (#530)

Co-authored-by: sinozu <sinozu@users.noreply.github.com>
Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
Shin Uozumi 2021-02-24 02:50:28 +09:00 committed by GitHub
parent cd42d0301a
commit f15abae92e
2 changed files with 13 additions and 2 deletions

View file

@ -244,8 +244,14 @@ func NewGitCloneExecutor(input NewGitCloneExecutorInput) Executor {
refType := "tag"
rev := plumbing.Revision(path.Join("refs", "tags", input.Ref))
if _, err := r.Tag(input.Ref); errors.Is(err, git.ErrTagNotFound) {
refType = "branch"
rev = plumbing.Revision(path.Join("refs", "remotes", "origin", input.Ref))
rName := plumbing.ReferenceName(path.Join("refs", "remotes", "origin", input.Ref))
if _, err := r.Reference(rName, false); errors.Is(err, plumbing.ErrReferenceNotFound) {
refType = "sha"
rev = plumbing.Revision(input.Ref)
} else {
refType = "branch"
rev = plumbing.Revision(rName)
}
}
hash, err := r.ResolveRevision(rev)
if err != nil {