Commit 9fbce64

Anton Medvedev <anton@medv.io>
2025-12-07 19:23:46
Use `DirName` for branch conflict detection in `hasConflictingBranchNames`. Improve error message for conflicting branch directory names in `main.go`.
1 parent f83d87d
Changed files (2)
main.go
@@ -136,7 +136,7 @@ func main() {
 	}
 
 	if yes, a, b := hasConflictingBranchNames(branches); yes {
-		echo(fmt.Sprintf("Conflicting branch names: %q and %q", a, b))
+		echo(fmt.Sprintf("Conflicting branchs %q and %q, both want to use %q dir name.", a, b, a.DirName()))
 		os.Exit(1)
 	}
 
utils.go
@@ -117,10 +117,10 @@ func containsBranch(branches []git.Ref, branch string) bool {
 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 {
+		if a, exists := uniq[b.DirName()]; exists {
 			return true, a, b
 		}
-		uniq[b.String()] = b
+		uniq[b.DirName()] = b
 	}
 	return false, git.Ref{}, git.Ref{}
 }