MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / BranchExists

Function BranchExists

internal/git/git.go:34–43  ·  view source on GitHub ↗

BranchExists returns true if a branch with the given name exists.

(dir, branchName string)

Source from the content-addressed store, hash-verified

32
33// BranchExists returns true if a branch with the given name exists.
34func BranchExists(dir, branchName string) (bool, error) {
35 cmd := exec.Command("git", "rev-parse", "--verify", branchName)
36 cmd.Dir = dir
37 err := cmd.Run()
38 if err != nil {
39 // Branch doesn't exist
40 return false, nil
41 }
42 return true, nil
43}
44
45// IsGitRepo returns true if the directory is inside a git repository.
46func IsGitRepo(dir string) bool {

Callers 3

TestDeleteBranchFunction · 0.85
GetDefaultBranchFunction · 0.85
CreateWorktreeFunction · 0.85

Calls 1

RunMethod · 0.80

Tested by 1

TestDeleteBranchFunction · 0.68