diff options
| author | Anton Medvedev <anton@medv.io> | 2025-12-07 20:21:11 +0100 |
|---|---|---|
| committer | Anton Medvedev <anton@medv.io> | 2025-12-07 20:21:11 +0100 |
| commit | f83d87db26e05aba1b0467744b5f4c3b80f85051 (patch) | |
| tree | 37e2f5f70f55c0debee301f878689bf151ca2232 | |
| parent | 05bb1363975dcbdbcf709d8d825f76f45061b847 (diff) | |
Add conflict detection for branches with identical names
| -rw-r--r-- | main.go | 5 | ||||
| -rw-r--r-- | utils.go | 11 |
2 files changed, 16 insertions, 0 deletions
@@ -135,6 +135,11 @@ func main() { os.Exit(1) } + if yes, a, b := hasConflictingBranchNames(branches); yes { + echo(fmt.Sprintf("Conflicting branch names: %q and %q", a, b)) + os.Exit(1) + } + // Start generating pages params := Params{ @@ -113,3 +113,14 @@ func containsBranch(branches []git.Ref, branch string) bool { } return false } + +func hasConflictingBranchNames(branches []git.Ref) (bool, git.Ref, git.Ref) { + uniq := make(map[string]git.Ref, len(branches)) + for _, b := range branches { + if a, exists := uniq[b.String()]; exists { + return true, a, b + } + uniq[b.String()] = b + } + return false, git.Ref{}, git.Ref{} +} |
