Allow dots in base branch names#94
Conversation
d0f543c to
752c1f0
Compare
752c1f0 to
96c19d6
Compare
There was a problem hiding this comment.
Pull request overview
Updates git-flow-next configuration loading so base branch names containing dots (e.g., custom.main) are correctly parsed from git config, addressing Issue #93 where git-flow overview didn’t recognize such branches.
Changes:
- Adjusted
LoadConfig()parsing ofgitflow.branch.*keys to treat everything betweengitflow.branch.and the final segment as the branch name (allowing embedded dots). - Added a unit test for
config.ApplyOverrides()to verify overridden base branch names containing dots propagate through derived branch settings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/config/config.go |
Fixes parsing of gitflow.branch.<branch>.<property> when <branch> includes dots. |
test/internal/config/config_test.go |
Adds coverage for override logic with dotted MainBranch / DevelopBranch values. |
| branchName := strings.ToLower(strings.Join(keyParts[2:len(keyParts)-1], ".")) | ||
| property := strings.ToLower(keyParts[len(keyParts)-1]) |
There was a problem hiding this comment.
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.
| @@ -270,6 +270,58 @@ func TestApplyOverrides_CustomBranchNames(t *testing.T) { | |||
| assert.False(t, exists) | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
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.
| // 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. |
There was a problem hiding this comment.
Clean, minimal fix for a real parsing bug — the approach of joining middle key parts for the branch name and taking the last part as the property is correct. However, the test doesn't exercise the actual code path that was changed.
Must Fix
- Test doesn't cover the fix —
test/internal/config/config_test.go:273—TestApplyOverrides_CustomBranchNamesWithDotstestsApplyOverrides, but the code change is inLoadConfig. A dotted branch name passed throughApplyOverridesalready worked (it's just a map key). The fix needs aLoadConfig-level test that sets git config keys likegitflow.branch.custom.main.typeand verifies they parse correctly.
Nit
- Stale comment —
internal/config/config.go:231— The comment// Parse key: gitflow.branch.<branchname>.<property>should note that<branchname>may contain dots.
🤖 Review generated with Claude Code
| @@ -270,6 +270,58 @@ func TestApplyOverrides_CustomBranchNames(t *testing.T) { | |||
| assert.False(t, exists) | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
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:
- Sets up a test repo
- Runs
git config gitflow.branch.custom.main.type base(and other properties) - Calls
config.LoadConfig() - Asserts the branch appears as
custom.mainin the loaded config
| 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]) |
There was a problem hiding this comment.
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.
Allow dots in base branch names.
Before changes:
Shell output for branch with dots
After changes:
Shell output for branch with dots
Resolves #93