1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-09-15 18:57:01 +00:00

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 a55d257be1
commit 2d5b34cfc2
2 changed files with 40 additions and 14 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")