feat(hotfix): namespace env branches per component and scope orphan detection - #522
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 yieldsenv/<component>/<env>; no component staysenv/<env>, byte-identical.ParseEnvBranchsplits on segment count, soenv/web/stagingparses to componentweb, envstaging(never envweb/staging), andenv/<env>parses exactly as before. This closes the naive-TrimPrefixfootgun.OrphanEnvBranches/HealOrphanEnvBranchestake a component and only inspect that component's ownenv/<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 ./... -raceclean,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.