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 7d0407fa4a
commit 97c083e902
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)
})
}