diff options
author | Markus Wolf <KnisterPeter@users.noreply.github.com> | 2023-03-09 21:03:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 21:03:13 +0100 |
commit | 6744e68ee29d3bcb6878f895d6ccb5f9f8e2c478 (patch) | |
tree | c3cbddb473fa717835b957b59702d9f15867b068 /pkg/model/github_context.go | |
parent | fix: return err in walk (#1667) (diff) | |
download | forgejo-act-6744e68ee29d3bcb6878f895d6ccb5f9f8e2c478.tar.xz forgejo-act-6744e68ee29d3bcb6878f895d6ccb5f9f8e2c478.zip |
fix: correct ref and ref_name (#1672)
* fix: correct ref and ref_name
The ref in the GitHub context is always full qualified
(e.g. refs/heads/branch, refs/tags/v1).
The ref_name is the ref with the strippep prefix.
In case of pull_requests, this is the merge commit ref
(e.g. refs/pull/123/merge -> 123/merge).
* test: update test data
Diffstat (limited to 'pkg/model/github_context.go')
-rw-r--r-- | pkg/model/github_context.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/model/github_context.go b/pkg/model/github_context.go index 9ce8d08..e4c31fc 100644 --- a/pkg/model/github_context.go +++ b/pkg/model/github_context.go @@ -103,7 +103,7 @@ func (ghc *GithubContext) SetRef(ctx context.Context, defaultBranch string, repo case "deployment", "deployment_status": ghc.Ref = asString(nestedMapLookup(ghc.Event, "deployment", "ref")) case "release": - ghc.Ref = asString(nestedMapLookup(ghc.Event, "release", "tag_name")) + ghc.Ref = fmt.Sprintf("refs/tags/%s", asString(nestedMapLookup(ghc.Event, "release", "tag_name"))) case "push", "create", "workflow_dispatch": ghc.Ref = asString(ghc.Event["ref"]) default: @@ -183,6 +183,9 @@ func (ghc *GithubContext) SetRefTypeAndName() { } else if strings.HasPrefix(ghc.Ref, "refs/heads/") { refType = "branch" refName = ghc.Ref[len("refs/heads/"):] + } else if strings.HasPrefix(ghc.Ref, "refs/pull/") { + refType = "" + refName = ghc.Ref[len("refs/pull/"):] } if ghc.RefType == "" { |