mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
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
This commit is contained in:
parent
e29fd4cac7
commit
8d098545de
3 changed files with 20 additions and 7 deletions
|
@ -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 == "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue