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

Function GetCurrentBranch

internal/git/git.go:11–19  ·  view source on GitHub ↗

GetCurrentBranch returns the current git branch name for a directory.

(dir string)

Source from the content-addressed store, hash-verified

9
10// GetCurrentBranch returns the current git branch name for a directory.
11func GetCurrentBranch(dir string) (string, error) {
12 cmd := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD")
13 cmd.Dir = dir
14 output, err := cmd.Output()
15 if err != nil {
16 return "", err
17 }
18 return strings.TrimSpace(string(output)), nil
19}
20
21// IsProtectedBranch returns true if the branch name is main or master.
22func IsProtectedBranch(branch string) bool {

Callers 5

startLoopForPRDMethod · 0.92
GetDiffFunction · 0.85
GetDiffStatsFunction · 0.85
CreateWorktreeFunction · 0.85
TestCreateWorktreeFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCreateWorktreeFunction · 0.68