stop naming a branch when pulling the capabilities repository
The plugin and capabilities repositories were standardised on `master`, and five places said `origin main` — the setup script's sync and the Update-all path. Swapping them to `master` would be the same mistake wearing a new name. `HEAD` resolves to whatever the remote's default is, so the question stops being asked, exactly as it now does for the marketplace icon URLs. Only the LOCAL branch still needs a name. Third time today that naming a branch was the bug: the icon URLs 404'd on four repositories created as `master`, and these would have broken the moment the rest were renamed to match. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,7 +85,9 @@ capabilities_sync() {
|
|||||||
local dir; dir="$(layout_items_dir)"
|
local dir; dir="$(layout_items_dir)"
|
||||||
|
|
||||||
if [[ -d "$dir/.git" ]]; then
|
if [[ -d "$dir/.git" ]]; then
|
||||||
(cd "$dir" && git pull --ff-only --quiet origin main 2>/dev/null) || return 1
|
# `HEAD` rather than a branch name — it resolves to the remote's default, so standardising the
|
||||||
|
# repositories on one name does not break this the way naming `main` did.
|
||||||
|
(cd "$dir" && git pull --ff-only --quiet origin HEAD 2>/dev/null) || return 1
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -99,7 +101,7 @@ capabilities_sync() {
|
|||||||
(cd "$dir" \
|
(cd "$dir" \
|
||||||
&& git init --quiet \
|
&& git init --quiet \
|
||||||
&& git remote add origin "$CAPABILITIES_REPO" 2>/dev/null \
|
&& git remote add origin "$CAPABILITIES_REPO" 2>/dev/null \
|
||||||
&& git fetch --quiet origin main \
|
&& git fetch --quiet origin HEAD \
|
||||||
&& git checkout --quiet -B main FETCH_HEAD) || return 1
|
&& git checkout --quiet -B master FETCH_HEAD) || return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,10 @@ export async function syncCapabilities(onLog?: OnLog): Promise<CapabilitiesResul
|
|||||||
return { ok: false, action: 'failed', error: `capabilities has ${tracked.length} uncommitted change(s)` };
|
return { ok: false, action: 'failed', error: `capabilities has ${tracked.length} uncommitted change(s)` };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const pulled = await git(dir, ['pull', '--ff-only', 'origin', 'main']);
|
// `HEAD`, not a branch name: it resolves to whatever the remote's default is. Naming `main` here
|
||||||
|
// broke the day the repositories were standardised on `master`, and naming `master` would break
|
||||||
|
// the day anything moves back. Same reasoning as the marketplace icon URLs.
|
||||||
|
const pulled = await git(dir, ['pull', '--ff-only', 'origin', 'HEAD']);
|
||||||
if (pulled.code !== 0) return { ok: false, action: 'failed', error: pulled.err || 'git pull failed' };
|
if (pulled.code !== 0) return { ok: false, action: 'failed', error: pulled.err || 'git pull failed' };
|
||||||
onLog?.('[capabilities] pulled');
|
onLog?.('[capabilities] pulled');
|
||||||
return { ok: true, action: 'pulled' };
|
return { ok: true, action: 'pulled' };
|
||||||
@@ -162,8 +165,9 @@ export async function syncCapabilities(onLog?: OnLog): Promise<CapabilitiesResul
|
|||||||
for (const argv of [
|
for (const argv of [
|
||||||
['init', '--quiet'],
|
['init', '--quiet'],
|
||||||
['remote', 'add', 'origin', CAPABILITIES_REPO],
|
['remote', 'add', 'origin', CAPABILITIES_REPO],
|
||||||
['fetch', '--quiet', 'origin', 'main'],
|
['fetch', '--quiet', 'origin', 'HEAD'],
|
||||||
['checkout', '--quiet', '-B', 'main', 'FETCH_HEAD'],
|
// The LOCAL branch still needs a name; the remote's default is whatever FETCH_HEAD just pointed at.
|
||||||
|
['checkout', '--quiet', '-B', 'master', 'FETCH_HEAD'],
|
||||||
]) {
|
]) {
|
||||||
const r = await git(dir, argv);
|
const r = await git(dir, argv);
|
||||||
// `remote add` fails when one is already there, which is not a problem worth stopping for.
|
// `remote add` fails when one is already there, which is not a problem worth stopping for.
|
||||||
|
|||||||
Reference in New Issue
Block a user