@pygmalionjs/pygmalion 0.5.12 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node/dev-mirror.mjs +18 -1
- package/package.json +1 -1
package/node/dev-mirror.mjs
CHANGED
|
@@ -253,13 +253,30 @@ export async function listSourceRefs(repoRoot, remote = 'origin') {
|
|
|
253
253
|
.filter((parts) => parts.length === 3 && parts[0])
|
|
254
254
|
.map(([name, commit, fullName]) => ({ name, commit, fullName }));
|
|
255
255
|
};
|
|
256
|
-
const locals = (await read('refs/heads')).map((item) => ({ ...item, kind: 'local' }));
|
|
257
256
|
const remotes = (await read(`refs/remotes/${remote}`))
|
|
258
257
|
// `%(refname:short)` may abbreviate refs/remotes/origin/HEAD to just
|
|
259
258
|
// `origin`, so the full ref is the only reliable way to remove the
|
|
260
259
|
// symbolic remote default from the branch picker.
|
|
261
260
|
.filter((item) => !item.fullName.endsWith('/HEAD'))
|
|
262
261
|
.map((item) => ({ ...item, kind: 'remote' }));
|
|
262
|
+
// `commit` is what SELECTING this entry would render, not what the listed ref
|
|
263
|
+
// happens to point at. Choosing a branch name repoints the mirror at that
|
|
264
|
+
// branch on the remote (syncDevMirrorWorktree fetches and resolves
|
|
265
|
+
// `<remote>/<name>`), so a local branch has to report its remote tip. Reading
|
|
266
|
+
// refs/heads instead made an editor name an OLDER commit as the update target
|
|
267
|
+
// whenever the local ref lagged behind what the mirror had already fetched —
|
|
268
|
+
// `dev@a0d5fdbf → 3e8cca5b`, an invitation to go backwards.
|
|
269
|
+
const remoteTipPrefix = `refs/remotes/${remote}/`;
|
|
270
|
+
const remoteTips = new Map(
|
|
271
|
+
remotes.map((item) => [item.fullName.slice(remoteTipPrefix.length), item.commit]),
|
|
272
|
+
);
|
|
273
|
+
const locals = (await read('refs/heads')).map((item) => ({
|
|
274
|
+
...item,
|
|
275
|
+
// A branch the remote does not have resolves locally (the fetch fails and
|
|
276
|
+
// becomes a warning), so its own tip is the honest answer there.
|
|
277
|
+
commit: remoteTips.get(item.name) ?? item.commit,
|
|
278
|
+
kind: 'local',
|
|
279
|
+
}));
|
|
263
280
|
const seen = new Set();
|
|
264
281
|
return [...locals, ...remotes].filter((item) => {
|
|
265
282
|
if (seen.has(item.name)) return false;
|