From 3bc8ddbfbfa5289d8b3becf852d4dbfc7f45a65a Mon Sep 17 00:00:00 2001 From: Donald Silveira <9506146+donnes@users.noreply.github.com> Date: Sun, 27 Sep 2026 21:49:02 -0300 Subject: [PATCH] docs: support upstream syncs from linked worktrees - Run syncs from a clean worktree branch without disturbing checked-out main - Use origin/main as the baseline and publish the merge with an explicit message --- .agents/skills/sync-upstream/SKILL.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.agents/skills/sync-upstream/SKILL.md b/.agents/skills/sync-upstream/SKILL.md index ff9812ffb93cb..c4ef75e345430 100644 --- a/.agents/skills/sync-upstream/SKILL.md +++ b/.agents/skills/sync-upstream/SKILL.md @@ -15,23 +15,29 @@ rebase: `main` is shared, and a rebase would rewrite every squash commit. ## Prepare 1. Add the remote if missing: `git remote add upstream git@github.com:pingdotgg/t3code.git`. -2. `git fetch origin upstream`. Require a clean tree on `main` with `main` equal to `origin/main`. Anything else stops the sync. -3. Record the **carry**, the fork's net delta over upstream, before touching anything: +2. `git fetch --multiple origin upstream` (plain `git fetch origin upstream` reads `upstream` as a ref on `origin` and fails). +3. Pick where the merge happens. It always starts from `origin/main` with a clean tree; a dirty tree stops the sync. + - **On `main`** (`git branch --show-current` prints `main`): require `main` equal to `origin/main`. + - **Anywhere else**, usually a linked worktree (`git rev-parse --git-dir` differs from `git rev-parse --git-common-dir`) where `main` is checked out in another checkout: leave that checkout alone. Git will not check out `main` twice, and the other checkout may be in use. Merge on the current branch instead, after `git reset --hard origin/main` when it has no commits of its own (`git log origin/main..HEAD` is empty); otherwise stop and ask. + + The steps below say `origin/main`, never local `main`, because local `main` can lag behind in either mode. + +4. Record the **carry**, the fork's net delta over upstream, before touching anything: ```bash - git log --oneline --no-merges upstream/main..main # fork commits - git diff --name-only $(git merge-base upstream/main main) main # fork-touched files + git log --oneline --no-merges upstream/main..origin/main # fork commits + git diff --name-only $(git merge-base upstream/main origin/main) origin/main # fork-touched files ``` Save the file list to a file outside the worktree. It is the completion check later. -4. Skim what is incoming: `git log --oneline main..upstream/main`. Note any upstream commit that lands the same feature a fork commit adds; it will need a decision in the merge. +5. Skim what is incoming: `git log --oneline origin/main..upstream/main`. Note any upstream commit that lands the same feature a fork commit adds; it will need a decision in the merge. ## Merge -Run `git merge upstream/main --no-edit`. With no conflicts, skip to Verify. +Run `git merge upstream/main -m "Merge upstream/main into main"`. The explicit message keeps the history reading the same whichever branch the merge ran on. With no conflicts, skip to Verify. -Resolve each conflict so both the upstream change and the fork change keep working. Read the fork commit that introduced the fork side (`git log -L` or `git blame` on `main`) before editing. Rules for the recurring cases: +Resolve each conflict so both the upstream change and the fork change keep working. Read the fork commit that introduced the fork side (`git log -L` or `git blame` on `origin/main`) before editing. Rules for the recurring cases: - **`pnpm-lock.yaml`**: take upstream's version, then run `vp i` to regenerate the fork's additions. - **`.repos/`**: take upstream's version. It is vendored reference material, never fork-edited. @@ -39,15 +45,15 @@ Resolve each conflict so both the upstream change and the fork change keep worki - **Same feature on both sides** (an upstream commit implements what a fork commit did): prefer upstream's implementation and drop the fork's, unless the fork version carries behavior upstream lacks. Record every dropped fork change for the report. - **Generated or formatted output**: resolve the source, then regenerate or run `vp fmt` on the file instead of hand-merging. -Finish with `git add` on each resolved file and `git merge --continue`. A merge going badly is undone with `git merge --abort`; `main` is back at `origin/main`. +Finish with `git add` on each resolved file and `git merge --continue`. A merge going badly is undone with `git merge --abort`; the branch is back at `origin/main`. ## Verify 1. `vp i`. If upstream bumped a dependency that has a vendored copy in `.repos/`, run `vpr sync:repos`. -2. Diff the carry: `git diff --name-only upstream/main main` must contain every file from the saved list. Each missing file is either a deliberate drop from the merge step or a bug to fix now. +2. Diff the carry: `git diff --name-only upstream/main HEAD` must contain every file from the saved list. Each missing file is either a deliberate drop from the merge step or a bug to fix now. 3. Typecheck and test the workspaces the carry touches, not the whole repo: `vp run --filter typecheck` and `vp test run ` for the carry's test files. Fix failures caused by upstream API changes in fork code; that is the normal cost of a sync. 4. Lint the files you edited during conflict resolution. ## Publish -Push with `git push origin main`. Then report: incoming commit count, each conflict and how it was resolved, every dropped fork change, and the verification commands with their results. +Push with `git push origin HEAD:main`; it must fast-forward, so re-fetch and stop if `origin/main` moved. When the merge ran off `main`, the other checkout's local `main` is now behind; say so and leave pulling it to the developer. Then report: incoming commit count, each conflict and how it was resolved, every dropped fork change, and the verification commands with their results.