Skip to content

feat(hotfix): namespace env branches per component and scope orphan detection - #522

Merged
joshua-temple merged 1 commit into
mainfrom
feat/hotfix-branch-namespace
Jul 8, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
feat/hotfix-branch-namespace

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

Problem

Hotfix environment branches and orphan detection are keyed by env alone. For multi-component repos a component's hotfix branch must be namespaced so it never collides with, or is mistaken for, a sibling's.

Fix

  • EnvBranchName(component, env): a selected component yields env/<component>/<env>; no component stays env/<env>, byte-identical.
  • ParseEnvBranch splits on segment count, so env/web/staging parses to component web, env staging (never env web/staging), and env/<env> parses exactly as before. This closes the naive-TrimPrefix footgun.
  • OrphanEnvBranches/HealOrphanEnvBranches take a component and only inspect that component's own env/<component>/* branches against its own state, so a component never flags or deletes a sibling's branch; the default component ignores every nested branch.

Scope is the naming and parsing primitives plus orphan detection. The finalize state write, tag scoping, and rejoin cleanup that consume them are separate changes.

Verification

go build ./..., go test ./... (2619 pass), go test ./... -race clean, golangci-lint run ./... clean; single-component byte-identical baseline gate green. Tests cover both branch-name forms, the nested-env parse (footgun), round-trip, per-component orphan scoping, and that a component's heal never deletes a sibling's branch.

Refs #293.

…etection

Hotfix environment branches for a selected component are now named env/<component>/<env>; with no component they stay env/<env>, byte-identical. EnvBranchName and ParseEnvBranch centralize construction and parsing: the parser splits on segment count so env/web/staging reads as component web, env staging, never env web/staging, while env/<env> parses exactly as before. OrphanEnvBranches and HealOrphanEnvBranches take a component and only ever inspect that component's own env/<component>/* branches against its own state, so a component never flags or deletes a sibling's branch and the default component ignores every nested branch. This lays the naming and parsing primitives; the finalize state write, tag scoping, and rejoin cleanup that consume them follow.

Refs #293.

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit c9699e8 into main Jul 8, 2026
20 checks passed
@joshua-temple
joshua-temple deleted the feat/hotfix-branch-namespace branch July 8, 2026 08:43
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.

1 participant