(t *testing.T, seedDir, remoteDir, branch, contents, message string)
| 453 | } |
| 454 | |
| 455 | func advanceRemoteBranchFromNewBranch(t *testing.T, seedDir, remoteDir, branch, contents, message string) { |
| 456 | t.Helper() |
| 457 | |
| 458 | seedRepo, err := git.PlainOpen(seedDir) |
| 459 | if err != nil { |
| 460 | t.Fatalf("open seed repo: %v", err) |
| 461 | } |
| 462 | worktree, err := seedRepo.Worktree() |
| 463 | if err != nil { |
| 464 | t.Fatalf("open seed worktree: %v", err) |
| 465 | } |
| 466 | if err := worktree.Checkout(&git.CheckoutOptions{Branch: plumbing.NewBranchReferenceName("master")}); err != nil { |
| 467 | t.Fatalf("checkout master before creating %s: %v", branch, err) |
| 468 | } |
| 469 | if err := worktree.Checkout(&git.CheckoutOptions{Branch: plumbing.NewBranchReferenceName(branch), Create: true}); err != nil { |
| 470 | t.Fatalf("create branch %s: %v", branch, err) |
| 471 | } |
| 472 | commitBranchMarker(t, seedDir, worktree, testBranchSpec{name: branch, contents: contents}, message) |
| 473 | if err := seedRepo.Push(&git.PushOptions{ |
| 474 | RemoteName: "origin", |
| 475 | RefSpecs: []gitconfig.RefSpec{ |
| 476 | gitconfig.RefSpec(plumbing.NewBranchReferenceName(branch).String() + ":" + plumbing.NewBranchReferenceName(branch).String()), |
| 477 | }, |
| 478 | }); err != nil { |
| 479 | t.Fatalf("push new branch %s update to %s: %v", branch, remoteDir, err) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | func findBranchSpec(branches []testBranchSpec, name string) (testBranchSpec, bool) { |
| 484 | for _, branch := range branches { |
no test coverage detected