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

fix: align github.ref to GitHub Action (#1362)

* fix: align github.ref to GitHub Action

The `github.ref` value should be `refs/heads/branch` in most cases.
There are a few exceptions handled by the code.

This change prefixes the default case with `refs/heads` and adds
tests for this and the excpetional cases.

* fix: correct existing assertions
This commit is contained in:
Markus Wolf 2022-09-27 00:49:19 +02:00 committed by GitHub
parent b5fe49c062
commit 9e5ca4d0a6
4 changed files with 52 additions and 7 deletions

View file

@ -40,7 +40,7 @@ func TestSetRefAndSha(t *testing.T) {
},
},
},
ref: "master",
ref: "refs/heads/master",
sha: "pr-base-sha",
},
{
@ -89,7 +89,7 @@ func TestSetRefAndSha(t *testing.T) {
"default_branch": "main",
},
},
ref: "main",
ref: "refs/heads/main",
sha: "1234fakesha",
},
{
@ -127,7 +127,7 @@ func TestSetRefAndSha(t *testing.T) {
ghc.SetRefAndSha(context.Background(), "", "/some/dir")
assert.Equal(t, "master", ghc.Ref)
assert.Equal(t, "refs/heads/master", ghc.Ref)
assert.Equal(t, "1234fakesha", ghc.Sha)
})
}