Upstream Patches

pulumi/agent-skills/package-maintenance/skills/upstream-patches

作者 pulumi900eacf4444f無授權條款70 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫昨天更新

Create, amend, remove, and rebase patches for Terraform provider submodules using `./scripts/upstream.sh`. Use when `upgrade-provider` or manual patch work needs owning-patch lookup, patch conflict fixes, patch/hunk removal, or upstream rebase.

AI 產生的概覽

使用 shell 指令碼工作流程管理疊加在 Terraform 供應商上游子模組之上的修補檔案。

功能
引導代理建立、修改、移除和重定基底疊加在上游 Terraform 供應商 git 子模組之上的修補檔案。它說明了初始化上游、將修補簽出為提交、重寫所屬修補提交,以及將提交寫回修補檔案的指令。也涵蓋尋找所屬修補、移除整個修補或選取的程式碼區塊,以及將修補重定基底到新的上游提交。
適用情境
適用於需要對 Terraform 供應商子模組進行修補工作的情境,例如修正現有修補引入的迴歸、移除某個修補或其中一部分,或將修補重定基底到更新的上游版本。當 upgrade-provider 自動化或手動修補維護需要尋找所屬修補或解決衝突時也適用。
執行需求
需要一個包含 upstream/ git 子模組和 patches/ 目錄的儲存庫,以及 ./scripts/upstream.sh 指令碼。使用 git 以及 ripgrep(rg)或 grep 進行修補搜尋。此技能不附帶指令碼,僅為說明文件。

Upstream Patches

upstream/ is a git submodule pointing to the upstream Terraform provider. patches/ contains patch files applied on top of it. Use ./scripts/upstream.sh to manage patch state.

Default Behavior

  • If fixing a regression introduced by an existing patch, amend the owning patch commit.
  • Do not create a new patch unless the user explicitly asks.

Commands Reference

CommandDescription
./scripts/upstream.sh initInitialize upstream and apply patches to working directory
./scripts/upstream.sh init -fDestructively discard checkout/rebase state and re-initialize upstream
./scripts/upstream.sh checkoutCreate branch with patches as commits for editing
./scripts/upstream.sh rebase -iInteractively edit patch commits
./scripts/upstream.sh rebase -o <commit>Rebase patches onto a new upstream commit
./scripts/upstream.sh check_inWrite commits back to patches and exit checkout mode

Guardrails

  • Never commit directly to upstream/ without checkout/check_in.
  • Direct edits under upstream/ outside checkout are ephemeral during upgrade-provider; the tool resets submodule state.
  • Do not hand-edit patches/*.patch unless intentionally doing raw patch surgery.
  • Prefer non-interactive rewrite flow over interactive rebase for agents.

Find Owning Patch First

Before editing patch content, identify the owning patch/commit.

bash
./scripts/upstream.sh checkout
# Find candidate patch files by touched file path or unique hunk textrg -n "path/to/file|unique_symbol" patches/*.patch
# Optional: inspect candidate patch header/hunkssed -n '1,120p' patches/00NN-Example.patch
# Map patch file to commit in upstream checkout branchpatch=patches/00NN-Example.patchsubject=$(sed -n 's/^Subject: \[PATCH\] //p' "$patch" | head -n1)cd upstreamgit log --oneline pulumi/patch-checkout --grep "$subject"
# If needed, disambiguate by touched pathgit log --oneline pulumi/patch-checkout -- path/to/filecd ..

If rg is unavailable, use grep -En for the patch search. Set target_sha to the owning commit and edit that commit, not HEAD.

Amend Existing Patch (Preferred, Non-Interactive)

bash
./scripts/upstream.sh checkoutcd upstream
target_sha=<owning-commit-sha>base_sha=$(git rev-parse "${target_sha}^")tmp_branch="rewrite-${target_sha:0:8}"
# Rebuild history from parent of target commitgit checkout -b "$tmp_branch" "$base_sha"git cherry-pick "$target_sha"
# Apply fix and amend target commit# ...edit files...git add <files>git commit --amend --no-edit
# Replay remaining commitsgit cherry-pick "${target_sha}..pulumi/patch-checkout"
# If cherry-pick conflicts occur:#   resolve files#   git add <resolved files>#   git cherry-pick --continue
# Move checkout branch to rewritten historygit branch -f pulumi/patch-checkout HEADgit checkout pulumi/patch-checkoutgit branch -D "$tmp_branch"cd ..

Interactive fallback:

bash
./scripts/upstream.sh checkout./scripts/upstream.sh rebase -i# mark target commit as edit, amend, then continue

Remove Entire Patch

Use when a patch should be deleted completely.

bash
rm patches/00NN-Description.patch./scripts/upstream.sh checkout./scripts/upstream.sh check_in

Remove Part of a Patch

Use when only selected hunks/files should be removed from an existing patch.

  1. Find owning patch/commit (target_sha) and use the amend workflow above.
  2. Revert only unwanted changes from the target commit, then amend.

Example during amend step:

bash
cd upstream# Restore specific docs-only files from parent of amended commitgit checkout HEAD^ -- path/to/docs-only-file path/to/another-doc-filegit add path/to/docs-only-file path/to/another-doc-filegit commit --amend --no-editcd ..

Create New Patch (Only If Requested)

bash
./scripts/upstream.sh checkoutcd upstream# ...make changes...git add <files>git commit -m "Describe new patch"cd .../scripts/upstream.sh check_in

Rebasing Patches to a New Upstream Version

bash
./scripts/upstream.sh checkout
# Rebase onto the new upstream commit./scripts/upstream.sh rebase -o <new_commit_sha># Resolve any conflicts that arise
# Write updated patch files./scripts/upstream.sh check_in

Verification Checklist

Before check_in:

  • Confirm expected patch count change (0 by default; -1 for full patch removal).
  • Confirm whether target patch should remain present (default yes) or be removed (explicit deletion case).
  • Confirm you are editing the owning commit, not adding a new commit by accident.

After check_in:

  • Verify patch count matches expectation.
  • Verify target patch number/purpose is still present when expected.
  • Verify no unexpected new 00NN-*.patch was introduced.

Interrupted Checkout or Rebase

Preserve work by default. Inspect git -C upstream status, complete the active git am/rebase, verify that every patch was applied, and run ./scripts/upstream.sh check_in before rerunning automation. An interrupted checkout invokes git am separately for each patch, so later patch files may not have been reached.

Use ./scripts/upstream.sh init -f only when intentionally discarding all interrupted work. It can remove conflict resolution, patch commits, operation metadata, and untracked files; it is not routine recovery for a stuck checkout.

來源與署名

來源:pulumi/agent-skills位於package-maintenance/skills/upstream-patches提交900eacf

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架