update a plugin whose local branch no longer exists on the remote

The Update button failed with "couldn't find remote ref main" on every checkout
made before the plugin repositories were standardised on `master`. It pulled
`origin <local branch name>`, and the local branch and the remote's default had
stopped agreeing — so the button could never work again on exactly the installs
that most needed it.

Now `git fetch origin HEAD` and a fast-forward: HEAD resolves to whatever the
remote's default is, so the local name stops mattering, and the merge applies it
to whichever branch the checkout happens to be on.

Fourth time today that naming a branch was the bug — the marketplace icon URLs,
the capabilities sync, the setup script, and now this. The rule that keeps
holding: fetch HEAD, never a name.

Verified by reproducing it — renamed a real checkout to `main`, pulled against a
remote that has only `master`, and it succeeded.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-19 13:00:32 +00:00
co-authored by Claude Opus 5
parent 0fd89082fe
commit 4b22f52c7e
+14 -1
View File
@@ -73,7 +73,20 @@ export async function pullPlugin(appName: string, onLog?: OnLog): Promise<PullRe
const branch = (await git(dir, ['rev-parse', '--abbrev-ref', 'HEAD'])).out;
onLog?.(`[${appName}] pulling ${branch}`);
const pulled = await git(dir, ['pull', '--ff-only', 'origin', branch]);
// FETCH `HEAD`, THEN FAST-FORWARD. Not `pull origin <local branch name>`.
//
// The local branch and the remote's default are two different things, and they stopped agreeing the
// day the plugin repositories were standardised: a checkout made before that is on `main`, the remote
// has only `master`, and `git pull origin main` fails with "couldn't find remote ref main" — an Update
// button that can never work again on exactly the installs that most need it.
//
// `HEAD` resolves to whatever the remote's default is, so the local name stops mattering. The
// fast-forward then applies it to whichever branch this checkout happens to be on.
const fetched = await git(dir, ['fetch', 'origin', 'HEAD']);
if (fetched.code !== 0) {
return { ok: false, updated: false, before, after: before, error: fetched.err || 'git fetch failed' };
}
const pulled = await git(dir, ['merge', '--ff-only', 'FETCH_HEAD']);
if (pulled.code !== 0) {
return { ok: false, updated: false, before, after: before, error: pulled.err || pulled.out || 'git pull failed' };
}