BranchExists returns true if a branch with the given name exists.
(dir, branchName string)
| 32 | |
| 33 | // BranchExists returns true if a branch with the given name exists. |
| 34 | func 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. |
| 46 | func IsGitRepo(dir string) bool { |