Skip to content

feat(scripts): add foreman-finalize.sh post-GO branch finalizer#1126

Merged
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/foreman-finalize
Jul 14, 2026
Merged

feat(scripts): add foreman-finalize.sh post-GO branch finalizer#1126
Defilan merged 1 commit into
defilantech:mainfrom
Defilan:feat/foreman-finalize

Conversation

@Defilan

@Defilan Defilan commented Jul 14, 2026

Copy link
Copy Markdown
Member

What

Adds scripts/foreman-finalize.sh: one command that turns a GO'd Foreman agentic-coding branch into a clean, single-commit PR against the base repo.

Why

A Foreman branchStrategy: reset revise commits the whole tree as a single commit whose message reflects only the last fix (so a feature gets labeled fix, misfiling the release-please changelog), and its base can lag the real base so its generated files (zz_generated deepcopy, CRDs) are stale and clobber already-merged work. Finalizing by hand is repetitive and error-prone; this codifies the safe steps.

How

Mechanic: re-apply the branch's source changes onto current base and regenerate derived artifacts, rather than copying the branch's possibly-stale generated files. Flow:

  1. Preflight: clean tree, gh auth, fetch base + fork branch, read the issue.
  2. Derive a conventional-commit subject from the issue ([FEATURE]feat, [BUG]fix; scope from a component/* label): type(scope): <title> (#N).
  3. Overlap guard: if a source file changed on both base and the branch since their merge-base, abort (no silent clobber).
  4. Assemble on a fresh finalize/<issue>-<slug> branch off base; make manifests generate chart-crds.
  5. Hard-stop verification: regen idempotency, go build, go vet, make validate-samples (--full-test adds make test).
  6. Single DCO-signed commit; Signed-off-by asserted.
  7. Push to the fork and open the PR (--dry-run prints the commands + message instead).

Remotes/repo/fork-owner are parameterized (defaults: upstream/main base, origin fork). Hard stops leave the branch intact for inspection.

Testing

  • shellcheck clean; bash -n parses.
  • --dry-run against a GO'd Foreman branch correctly hit the overlap guard (its feature had already merged), and against a synthetic branch based on current main ran the full happy path (assemble → regen → idempotency → build/vet/validate-samples → DCO commit → printed push + gh pr create + message/body) and cleanly restored the original branch. No mock-git harness (out of scope for v1).

Checklist

  • shellcheck clean
  • --dry-run exercised (overlap-guard path and happy path)
  • DCO sign-off
  • No functional code changes (adds a maintainer script only)

AI assistance

Designed and implemented with AI assistance (Claude Code); reviewed and owned by the author. Band-3 disclosure per the project's AI-assisted contribution policy.

Rebase a GO'd Foreman agentic-coding branch onto current base by re-applying
its source changes and regenerating derived artifacts (never copying the
branch's possibly-stale generated files), drift-check the regen, squash to one
commit with an issue-derived conventional-commit subject, and open the PR.

Full-auto to PR with hard stops (dirty tree, source/base overlap, non-idempotent
codegen, build/vet/validate-samples failure, missing sign-off). --dry-run
previews without touching GitHub. Remotes/repo/fork-owner are parameterized.

Motivated by finalizing defilantech#1098 by hand: a branchStrategy=reset revise produced a
single commit mislabeled fix-vs-feat, and its stale generated deepcopy reverted
another merged PR's methods.

Signed-off-by: Christopher Maher <chris@mahercode.io>
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Defilan Defilan merged commit 8d17e25 into defilantech:main Jul 14, 2026
8 checks passed
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