feat(promote): rejoin and clean up diverged envs on inbound promotion - #105
Merged
Merged
Conversation
When a promotion into a diverged environment passes the patch-containment gate and finalizes, the environment rejoins trunk: clear ref/base_sha/patches, delete the env/<env> integration branch, and remove the hotfix tags and release drafts minted for that base. Add a status consistency check that flags env/* branches with no matching manifest divergence (orphan integration branches). Cleanup is gated on prior divergence and injected through a no-op LifecycleCleaner, so a normal promotion into a non-diverged environment touches none of it. Adds git helpers for remote branch/tag deletion and remote branch listing. 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
A hotfix diverges an environment onto an
env/<name>integration branch with its own hotfix tag and release draft. Nothing yet ends that divergence: when a normal promotion brings a containing trunk SHA into the env, the divergence fields, branch, tags, and drafts were left behind, and there was no way to spot orphanenv/*branches.Fix
When a promotion into a diverged environment finalizes (the preflight patch-containment gate having already passed), the env rejoins trunk:
ref/base_sha/patcheson that env's state.env/<env>integration branch on the remote.vX.Y.Z-rc.N.hotfix.M) and their release drafts. The RC-shaped cleanup deliberately cannot see these, so they are collected explicitly.The cleanup is gated on the env having been diverged and is injected through a
LifecycleCleanerwith a no-op default, so a normal promotion into a non-diverged environment touches none of the new logic. A newcascade status consistencysubcommand flagsenv/*branches that have no matching manifest divergence (orphan integration branches).Supporting
internal/githelpers added:DeleteRemoteBranch,DeleteRemoteTag,ListRemoteBranches(all idempotent on already-absent refs).Verification
go build ./...go test ./...(1131 passing, 20 packages)go test -race ./internal/promote/ ./internal/hotfix/ ./internal/git/ ./internal/status/golangci-lint run ./internal/promote/... ./internal/release/... ./internal/hotfix/... ./internal/status/...(clean)Coverage: focused unit tests for rejoin field-clearing, branch deletion, tag/draft cleanup, other-env preservation, the non-diverged negative path, and the orphan-branch consistency check, plus a full-lifecycle integration test against a real git repository and a release-stub server.
The act/gitea hotfix e2e scenarios (including rejoin/cleanup) are owned by the e2e harness unit and are intentionally deferred here; this PR's bar is unit plus scratch-repo plus release-stub integration coverage. Confined to
internal/promote,internal/git,internal/hotfix,internal/status;internal/generateis untouched.