Skip to content

Add regenerate-override-patches.sh to automate coupled override-patch regeneration - #299

Open
xyos wants to merge 1 commit into
mainfrom
tooling/regenerate-override-patches
Open

Add regenerate-override-patches.sh to automate coupled override-patch regeneration#299
xyos wants to merge 1 commit into
mainfrom
tooling/regenerate-override-patches

Conversation

@xyos

@xyos xyos commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Issue

Description of Changes

Adds scripts/patches/regenerate-override-patches.sh, which automates regenerating @generated override patches and healing the rest of the quilt series.

Background: patches generated by scripts/patches/apply-override.sh rewrite shared blocks in package.json (for example the root overrides object). Changing the version in one such patch invalidates the diff context of every later @generated patch in the series, which today means a slow manual conflict-resolution loop with quilt push -f / edit / quilt refresh per patch.

The new script makes this a single command:

scripts/patches/regenerate-override-patches.sh \
  --set 'undici=^7.30.0' \
  common/finding-override-undici.diff

Behavior:

  • Each named patch must be an existing @generated patch. The script re-reads the apply-override.sh command stored in the patch's @generator metadata line and re-executes it (the free-text header is extracted from the patch and re-passed via --header).
  • --set 'PACKAGE=VERSION' (repeatable) rewrites the version for that package in the named patches' @generator specs and header text before regenerating, so a version bump needs no manual edits.
  • After each regeneration it runs prepare-src.sh --command rebase_patches <target>. If the rebase stops on a conflicted patch that is itself @generated, the script force-pops it, empties the stale patch file, and regenerates it deterministically from its own @generator line, then rebases again (capped at 25 iterations). If the conflicted patch is not @generated, it stops and prints the manual quilt refresh instructions.
  • --target <t> selects the series to rebase (default code-editor-sagemaker-server); --dry-run prints every command it would run without executing.

Also updates apply-override.sh to honor a pre-set QUILT_SERIES instead of always picking the first *.series file found, so the target's series is respected (falls back to the old behavior when unset).

Testing

All runs inside the code-editor-ubuntu container against a full checkout:

  • Dry run (--dry-run --set 'undici=^7.29.0' --set 'ip-address=^10.3.1' common/finding-override-undici.diff common/finding-override-ip-address.diff): exits 0 and prints the exact apply-override.sh / prepare-src.sh commands it would execute.
  • Idempotent run (re-setting the current versions with the same command minus --dry-run): exits 0, git diff on the two named patches is empty, and a strict ./scripts/prepare-src.sh code-editor-sagemaker-server passes afterwards.
  • Heal-path run (--set 'undici=^7.30.0' common/finding-override-undici.diff): the bump broke the context of finding-override-form-data.diff and then finding-override-tar.diff; both were regenerated automatically from their own @generator lines, the loop converged in 4 rebase iterations, exit 0, and strict prepare-src.sh passes with ^7.30.0 present in the header, @generator, @override-package, and all hunks of the undici patch.
  • Error paths: unknown --target, non-@generated patch, and missing patch arguments all fail fast with clear messages.

Screenshots/Videos

Additional Notes

The rebase loop reuses prepare-src.sh --command rebase_patches, which refreshes each patch as it re-applies. On a tree with mixed diff-header styles this can normalize the headers of a few untouched patches on the first run; the result is deterministic and stable on subsequent runs.

Backporting

Not needed; developer tooling only.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@xyos
xyos requested a review from a team as a code owner August 8, 2026 20:21
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