getCurrentBranch returns the current git branch name.
()
| 60 | |
| 61 | // getCurrentBranch returns the current git branch name. |
| 62 | func 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. |
| 71 | var itemRefPattern = regexp.MustCompile(`([A-Z]+-\d+)`) |