Skip to content

Allow dots in base branch names#94

Open
nkoshell wants to merge 1 commit intogittower:mainfrom
nkoshell:feature/dots-in-base-branch-names
Open

Allow dots in base branch names#94
nkoshell wants to merge 1 commit intogittower:mainfrom
nkoshell:feature/dots-in-base-branch-names

Conversation

@nkoshell
Copy link
Copy Markdown

@nkoshell nkoshell commented Mar 31, 2026

Allow dots in base branch names.

Before changes:

Shell output for branch with dots
/ $ mkdir -p /tmp/git-flow-check
/ $ cd /tmp/git-flow-check/
/tmp/git-flow-check $ git init
/tmp/git-flow-check $ git-flow init --preset=classic --main=custom.main --develop=custom.dev
Initializing git-flow with classic preset
Created branch 'custom.main'
Created branch 'custom.dev'
Git flow has been initialized
/tmp/git-flow-check $ git-flow overview
Base branches:
==============

Topic branch types:
===================
bugfix/*:
  Parent: custom.dev
  Merges into custom.dev, Rebases onto from custom.dev

release/*:
  Parent: custom.main
  Start point: custom.dev
  Merges into custom.main, Merges from custom.main
  Creates tags on finish

hotfix/*:
  Parent: custom.main
  Merges into custom.main, Rebases onto from custom.main
  Creates tags on finish

support/*:
  Parent: custom.main
  none into custom.main, none from custom.main

feature/*:
  Parent: custom.dev
  Merges into custom.dev, Rebases onto from custom.dev

Active topic branches:
======================
  No active topic branches

After changes:

Shell output for branch with dots
/ $ mkdir -p /tmp/git-flow-check
/ $ cd /tmp/git-flow-check/
/tmp/git-flow-check $ git init
/tmp/git-flow-check $ git-flow init --preset=classic --main=custom.main --develop=custom.dev
Initializing git-flow with classic preset
Created branch 'custom.main'
Created branch 'custom.dev'
Git flow has been initialized
/tmp/git-flow-check $ git-flow overview
Base branches:
==============
  custom.main (root)
  custom.dev → custom.main [auto-update]

Topic branch types:
===================
feature/*:
  Parent: custom.dev
  Merges into custom.dev, Rebases onto from custom.dev

bugfix/*:
  Parent: custom.dev
  Merges into custom.dev, Rebases onto from custom.dev

release/*:
  Parent: custom.main
  Start point: custom.dev
  Merges into custom.main, Merges from custom.main
  Creates tags on finish

hotfix/*:
  Parent: custom.main
  Merges into custom.main, Rebases onto from custom.main
  Creates tags on finish

support/*:
  Parent: custom.main
  none into custom.main, none from custom.main

Active topic branches:
======================
  No active topic branches

Resolves #93

@nkoshell nkoshell force-pushed the feature/dots-in-base-branch-names branch from d0f543c to 752c1f0 Compare March 31, 2026 10:53
@nkoshell nkoshell force-pushed the feature/dots-in-base-branch-names branch from 752c1f0 to 96c19d6 Compare March 31, 2026 11:10
@alexrinass alexrinass requested a review from Copilot April 6, 2026 09:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 of gitflow.branch.* keys to treat everything between gitflow.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.

Comment thread internal/config/config.go
Comment on lines +237 to +238
branchName := strings.ToLower(strings.Join(keyParts[2:len(keyParts)-1], "."))
property := strings.ToLower(keyParts[len(keyParts)-1])
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.
@@ -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

@alexrinass alexrinass left a comment

Choose a reason for hiding this comment

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

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:273TestApplyOverrides_CustomBranchNamesWithDots tests ApplyOverrides, but the code change is in LoadConfig. A dotted branch name passed through ApplyOverrides already worked (it's just a map key). The fix needs a LoadConfig-level test that sets git config keys like gitflow.branch.custom.main.type and 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)
}

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

Comment thread internal/config/config.go
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])
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow dots in base branch names

3 participants