Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ func LoadConfig() (*Config, error) {
continue
}

branchName := strings.ToLower(keyParts[2])
property := strings.ToLower(keyParts[3])
branchName := strings.ToLower(strings.Join(keyParts[2:len(keyParts)-1], "."))
property := strings.ToLower(keyParts[len(keyParts)-1])
Comment on lines +237 to +238
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated LoadConfig parsing now supports branch names that contain dots, but there’s no regression test that exercises reading such keys from git config (e.g., gitflow.branch.custom.main.type). The new unit test only covers ApplyOverrides, which doesn’t validate the git config --get-regexp gitflow\.branch\. parsing logic; please add a test that writes dotted branch keys into a temp repo and asserts config.LoadConfig() (or git-flow overview) recognizes the base branches correctly.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct. Minor: the comment on line 231 above (// Parse key: gitflow.branch.<branchname>.<property>) should be updated to reflect that <branchname> may contain dots.


// Initialize branch map if needed
if _, ok := branchMap[branchName]; !ok {
Expand Down
52 changes: 52 additions & 0 deletions test/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,58 @@ func TestApplyOverrides_CustomBranchNames(t *testing.T) {
assert.False(t, exists)
}

Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new test is missing the standard structured header comment used across the test suite (summary line + // Steps: list). Adding it will make the intent and setup steps consistent with the rest of the repo’s tests.

Suggested change
// TestApplyOverrides_CustomBranchNamesWithDots validates that ApplyOverrides
// correctly updates branch relationships when custom branch names contain dots.
// Steps:
// 1. Create the default configuration.
// 2. Apply overrides using dotted names for the main and develop branches.
// 3. Verify the renamed base branches have the expected type, parent, and start point.
// 4. Verify dependent branch types reference the updated dotted branch names.
// 5. Verify the original default branch names no longer exist in the configuration.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only exercises ApplyOverrides, not LoadConfig where the parsing fix actually lives. ApplyOverrides already handled dotted names correctly since it just renames map keys.

Add a TestLoadConfigWithDottedBranchNames test (similar to TestLoadConfigCaseInsensitive at line 54) that:

  1. Sets up a test repo
  2. Runs git config gitflow.branch.custom.main.type base (and other properties)
  3. Calls config.LoadConfig()
  4. Asserts the branch appears as custom.main in the loaded config

func TestApplyOverrides_CustomBranchNamesWithDots(t *testing.T) {
cfg := config.DefaultConfig()
cfg = config.ApplyOverrides(cfg, config.ConfigOverrides{
MainBranch: "custom.main",
DevelopBranch: "custom.dev",
})

// Check main branch (base branch)
mainConfig, exists := cfg.Branches["custom.main"]
assert.True(t, exists)
assert.Equal(t, string(config.BranchTypeBase), mainConfig.Type)
assert.Equal(t, "", mainConfig.Parent)
assert.Equal(t, "", mainConfig.StartPoint)

// Check develop branch (base branch)
developConfig, exists := cfg.Branches["custom.dev"]
assert.True(t, exists)
assert.Equal(t, string(config.BranchTypeBase), developConfig.Type)
assert.Equal(t, "custom.main", developConfig.Parent)
assert.Equal(t, "", developConfig.StartPoint)

// Check feature branch parent and start point
featureConfig, exists := cfg.Branches["feature"]
assert.True(t, exists)
assert.Equal(t, "custom.dev", featureConfig.Parent)
assert.Equal(t, "custom.dev", featureConfig.StartPoint)

// Check release branch parent and start point
releaseConfig, exists := cfg.Branches["release"]
assert.True(t, exists)
assert.Equal(t, "custom.main", releaseConfig.Parent)
assert.Equal(t, "custom.dev", releaseConfig.StartPoint)

// Check hotfix branch parent and start point
hotfixConfig, exists := cfg.Branches["hotfix"]
assert.True(t, exists)
assert.Equal(t, "custom.main", hotfixConfig.Parent)
assert.Equal(t, "custom.main", hotfixConfig.StartPoint)

// Check support branch parent and start point
supportConfig, exists := cfg.Branches["support"]
assert.True(t, exists)
assert.Equal(t, "custom.main", supportConfig.Parent)
assert.Equal(t, "custom.main", supportConfig.StartPoint)

// Check old names don't exist
_, exists = cfg.Branches["main"]
assert.False(t, exists)
_, exists = cfg.Branches["develop"]
assert.False(t, exists)
}

func TestApplyOverrides_CustomPrefixes(t *testing.T) {
cfg := config.DefaultConfig()
cfg = config.ApplyOverrides(cfg, config.ConfigOverrides{
Expand Down