writeFakeGitConfig creates a .git/config under dir with the given origin URL. Returns the absolute dir path.
(t *testing.T, dir, originURL string)
| 11 | // writeFakeGitConfig creates a .git/config under dir with the given origin |
| 12 | // URL. Returns the absolute dir path. |
| 13 | func writeFakeGitConfig(t *testing.T, dir, originURL string) { |
| 14 | t.Helper() |
| 15 | gitDir := filepath.Join(dir, ".git") |
| 16 | if err := os.MkdirAll(gitDir, 0o755); err != nil { |
| 17 | t.Fatal(err) |
| 18 | } |
| 19 | cfg := `[core] |
| 20 | repositoryformatversion = 0 |
| 21 | [remote "origin"] |
| 22 | url = ` + originURL + ` |
| 23 | fetch = +refs/heads/*:refs/remotes/origin/* |
| 24 | [branch "main"] |
| 25 | remote = origin |
| 26 | ` |
| 27 | if err := os.WriteFile(filepath.Join(gitDir, "config"), []byte(cfg), 0o644); err != nil { |
| 28 | t.Fatal(err) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func TestCmdWorkdirAddManualName(t *testing.T) { |
| 33 | root := setupArchiveTestEnv(t) |
no outgoing calls
no test coverage detected