writeGHConfig writes gh's config the way gh auth login --insecure-storage leaves it, logged in to host as fakeUser with fakeToken. That's where a user's login lives. A token in GH_TOKEN would also apply to github.com, so in --localhost runs gh auth status would check github.com too, which ghmock blo
(dir, host string, loggedIn bool)
| 482 | // blocks. The config version marks the multi-account migration as done, as it |
| 483 | // is for anyone who has logged in with a recent gh. |
| 484 | func writeGHConfig(dir, host string, loggedIn bool) error { |
| 485 | if err := os.WriteFile(filepath.Join(dir, "config.yml"), []byte("version: \"1\"\n"), 0o600); err != nil { |
| 486 | return err |
| 487 | } |
| 488 | if !loggedIn { |
| 489 | return nil |
| 490 | } |
| 491 | hosts := fmt.Sprintf(`%[1]s: |
| 492 | users: |
| 493 | %[2]s: |
| 494 | oauth_token: %[3]s |
| 495 | git_protocol: https |
| 496 | oauth_token: %[3]s |
| 497 | user: %[2]s |
| 498 | `, host, fakeUser, fakeToken) |
| 499 | return os.WriteFile(filepath.Join(dir, "hosts.yml"), []byte(hosts), 0o600) |
| 500 | } |
| 501 | |
| 502 | // hideScratch replaces the run's scratch folder with <scratch> in gh's |
| 503 | // output. Each binary gets its own folder, so paths such as the hosts.yml |