MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / advanceRemoteBranchFromNewBranch

Function advanceRemoteBranchFromNewBranch

internal/store/gitstore_test.go:455–481  ·  view source on GitHub ↗
(t *testing.T, seedDir, remoteDir, branch, contents, message string)

Source from the content-addressed store, hash-verified

453}
454
455func 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
483func findBranchSpec(branches []testBranchSpec, name string) (testBranchSpec, bool) {
484 for _, branch := range branches {

Calls 3

commitBranchMarkerFunction · 0.85
PushMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected