Commit f83d87d

Anton Medvedev <anton@medv.io>
2025-12-07 19:21:11
Add conflict detection for branches with identical names
1 parent 05bb136
Changed files (2)
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{
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{}
+}