summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Medvedev <anton@medv.io>2025-12-07 20:21:11 +0100
committerAnton Medvedev <anton@medv.io>2025-12-07 20:21:11 +0100
commitf83d87db26e05aba1b0467744b5f4c3b80f85051 (patch)
tree37e2f5f70f55c0debee301f878689bf151ca2232
parent05bb1363975dcbdbcf709d8d825f76f45061b847 (diff)
Add conflict detection for branches with identical names
-rw-r--r--main.go5
-rw-r--r--utils.go11
2 files changed, 16 insertions, 0 deletions
diff --git a/main.go b/main.go
index c68588d..d6d2ab6 100644
--- a/main.go
+++ b/main.go
@@ -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{
diff --git a/utils.go b/utils.go
index 2ad68d5..9a53de3 100644
--- a/utils.go
+++ b/utils.go
@@ -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{}
+}