MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / getCurrentBranch

Function getCurrentBranch

cmd/pad/cmd_github.go:62–68  ·  view source on GitHub ↗

getCurrentBranch returns the current git branch name.

()

Source from the content-addressed store, hash-verified

60
61// getCurrentBranch returns the current git branch name.
62func getCurrentBranch() (string, error) {
63 out, err := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output()
64 if err != nil {
65 return "", fmt.Errorf("not in a git repository or git not available")
66 }
67 return strings.TrimSpace(string(out)), nil
68}
69
70// extractItemRefFromBranch attempts to find a Pad item reference (e.g. TASK-5, BUG-3) in a branch name.
71var itemRefPattern = regexp.MustCompile(`([A-Z]+-\d+)`)

Callers 1

githubLinkCmdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected