MCPcopy Create free account
hub / github.com/github/gh-aw / switchBranch

Function switchBranch

pkg/cli/git.go:477–486  ·  view source on GitHub ↗

switchBranch switches to the specified branch

(branchName string, verbose bool)

Source from the content-addressed store, hash-verified

475
476// switchBranch switches to the specified branch
477func switchBranch(branchName string, verbose bool) error {
478 console.LogVerbose(verbose, "Switching to branch: "+branchName)
479
480 cmd := exec.Command("git", "checkout", branchName)
481 if err := cmd.Run(); err != nil {
482 return fmt.Errorf("failed to switch to branch %s: %w", branchName, err)
483 }
484
485 return nil
486}
487
488// commitChanges commits all staged changes with the given message
489func commitChanges(message string, verbose bool) error {

Callers 4

TestSwitchBranchFunction · 0.85
updateLocalBranchMethod · 0.85
CreatePRWithChangesFunction · 0.85
addWorkflowsWithPRFunction · 0.85

Calls 3

LogVerboseFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by 1

TestSwitchBranchFunction · 0.68