tests/thirdparty: use shallow clone (#224)

When trying to add a test case from the standard library, cloning golang/go
was taking forever. This PR switches to a shallow clone.
This commit is contained in:
Michael McLoughlin
2021-11-07 16:30:50 -08:00
committed by GitHub
parent f355d27b13
commit 1de006d741

View File

@@ -71,17 +71,18 @@ func (t *PackageTest) Run() {
// checkout the code at the specified version. // checkout the code at the specified version.
func (t *PackageTest) checkout() { func (t *PackageTest) checkout() {
// Clone repo. // Determine the version we want to checkout.
dst := filepath.Join(t.WorkDir, t.Name()) version := t.Version
test.Exec(t.T, "git", "clone", "--quiet", t.Repository.CloneURL(), dst)
t.repopath = dst
// Checkout specific version.
if t.Latest { if t.Latest {
t.Log("using latest version") version = t.DefaultBranch
return
} }
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "--quiet", t.Version)
// Clone. Use a shallow clone to speed up large repositories.
t.repopath = filepath.Join(t.WorkDir, t.Name())
test.Exec(t.T, "git", "init", t.repopath)
test.Exec(t.T, "git", "-C", t.repopath, "remote", "add", "origin", t.Repository.CloneURL())
test.Exec(t.T, "git", "-C", t.repopath, "fetch", "--depth=1", "origin", version)
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD")
} }
func (t *PackageTest) steps() { func (t *PackageTest) steps() {