MCPcopy Create free account
hub / github.com/docker/secrets-engine / newGitRepoWithRemote

Function newGitRepoWithRemote

x/release/command_test.go:62–80  ·  view source on GitHub ↗

newGitRepoWithRemote creates a working clone whose origin is a local bare repo, with origin/HEAD pointing at main, and HEAD at the remote tip.

(t *testing.T)

Source from the content-addressed store, hash-verified

60// newGitRepoWithRemote creates a working clone whose origin is a local bare
61// repo, with origin/HEAD pointing at main, and HEAD at the remote tip.
62func newGitRepoWithRemote(t *testing.T) *gitRepo {
63 t.Helper()
64 root := t.TempDir()
65 bare := filepath.Join(root, "origin.git")
66 work := filepath.Join(root, "work")
67
68 runGitIn(t, root, "init", "--bare", "--initial-branch=main", bare)
69
70 r := &gitRepo{dir: work}
71 runGitIn(t, root, "clone", bare, work)
72 r.config(t)
73 require.NoError(t, os.WriteFile(filepath.Join(work, "README.md"), []byte("seed\n"), 0o644))
74 r.run(t, "add", "README.md")
75 r.run(t, "commit", "-m", "seed")
76 r.run(t, "push", "-u", "origin", "main")
77 // Make origin/HEAD resolvable so remoteDefaultBranch finds it.
78 r.run(t, "remote", "set-head", "origin", "main")
79 return r
80}
81
82func (r *gitRepo) config(t *testing.T) {
83 t.Helper()

Callers 1

Test_verifyReleaseRefFunction · 0.85

Calls 3

configMethod · 0.95
runMethod · 0.95
runGitInFunction · 0.85

Tested by

no test coverage detected