Fix "reference not found" error on checkout (#433) (#471)

This commit is contained in:
KADOTA, Kyohei
2021-01-15 14:24:17 +09:00
committed by GitHub
parent 460ed2db04
commit 6e1cdeefc0
4 changed files with 44 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
package common
import (
"context"
"fmt"
"io/ioutil"
"os"
@@ -169,6 +170,37 @@ func TestGitFindRef(t *testing.T) {
}
}
func TestGitCloneExecutor(t *testing.T) {
for name, tt := range map[string]struct {
URL string
Ref string
Err error
}{
"tag": {
URL: "https://github.com/actions/checkout",
Ref: "v2",
Err: nil,
},
"branch": {
URL: "https://github.com/anchore/scan-action",
Ref: "act-fails",
Err: nil,
},
} {
tt := tt
name := name
t.Run(name, func(t *testing.T) {
clone := NewGitCloneExecutor(NewGitCloneExecutorInput{
URL: tt.URL,
Ref: tt.Ref,
Dir: testDir(t),
})
err := clone(context.Background())
assert.ErrorIs(t, err, tt.Err)
})
}
}
func gitConfig() {
if os.Getenv("GITHUB_ACTIONS") == "true" {
_ = gitCmd("config", "--global", "user.email", "test@test.com")