Skip to content

Commit fb227a1

Browse files
committed
fix: preserve original case in branch names
1 parent 5a604f7 commit fb227a1

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

session/git/util.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ import (
1111
// Note: Git branch names have several rules, so this function uses a simple approach
1212
// by allowing only a safe subset of characters.
1313
func sanitizeBranchName(s string) string {
14-
// Convert to lower-case
15-
s = strings.ToLower(s)
16-
1714
// Replace spaces with a dash
1815
s = strings.ReplaceAll(s, " ", "-")
1916

2017
// Remove any characters not allowed in our safe subset.
2118
// Here we allow: letters, digits, dash, underscore, slash, and dot.
22-
re := regexp.MustCompile(`[^a-z0-9\-_/.]+`)
19+
re := regexp.MustCompile(`[^a-zA-Z0-9\-_/.]+`)
2320
s = re.ReplaceAllString(s, "")
2421

2522
// Replace multiple dashes with a single dash (optional cleanup)

session/git/util_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestSanitizeBranchName(t *testing.T) {
2323
{
2424
name: "mixed case string",
2525
input: "FeAtUrE BrAnCh",
26-
expected: "feature-branch",
26+
expected: "FeAtUrE-BrAnCh",
2727
},
2828
{
2929
name: "string with special characters",
@@ -58,7 +58,7 @@ func TestSanitizeBranchName(t *testing.T) {
5858
{
5959
name: "complex mixed case with special chars",
6060
input: "USER/Feature Branch!@#$%^&*()/v1.0",
61-
expected: "user/feature-branch/v1.0",
61+
expected: "USER/Feature-Branch/v1.0",
6262
},
6363
}
6464

0 commit comments

Comments
 (0)