@pygmalionjs/pygmalion 0.5.10 → 0.5.11

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.
@@ -556,7 +556,17 @@ export async function syncDevMirrorWorktree(options) {
556
556
  let warning = null;
557
557
  let switchTarget = null;
558
558
 
559
- if (localRef) {
559
+ // A pinned commit must never move: that is the whole point of pinning, and
560
+ // fetching behind a designer's back would silently change what a captured
561
+ // frame means. A branch NAME is the opposite promise — asking for `dev` means
562
+ // "whatever dev is now", so it has to reach the remote first.
563
+ //
564
+ // Conflating the two made the consumer's "refresh branch" button re-read a
565
+ // local ref and never advance: it looked like the newest dev and was whatever
566
+ // the machine last happened to fetch.
567
+ const pinnedCommit = localRef != null && /^[0-9a-f]{7,40}$/i.test(localRef);
568
+
569
+ if (localRef && pinnedCommit) {
560
570
  try {
561
571
  switchTarget = await git(
562
572
  repoRoot,
@@ -568,6 +578,35 @@ export async function syncDevMirrorWorktree(options) {
568
578
  } catch {
569
579
  throw new Error(`local source.ref "${localRef}" cannot be interpreted as a commit`);
570
580
  }
581
+ } else if (localRef) {
582
+ // `origin/dev` and `dev` both mean the same branch here; strip the remote so
583
+ // the fetch names a branch and the result is read back from the remote ref.
584
+ const namedBranch = localRef.startsWith(`${remote}/`)
585
+ ? localRef.slice(remote.length + 1)
586
+ : localRef;
587
+ const namedRemoteRef = `${remote}/${namedBranch}`;
588
+ try {
589
+ await git(repoRoot, 'fetch', remote, namedBranch);
590
+ switchTarget = namedRemoteRef;
591
+ } catch (error) {
592
+ // Offline is not fatal — fall back to whatever the ref resolves to
593
+ // locally, and say so rather than pretending the branch is current.
594
+ warning = `source.ref "${localRef}" could not be refreshed from ${remote}: ${
595
+ error instanceof Error ? error.message.split('\n')[0] : String(error)
596
+ }`;
597
+ options.onWarning?.(warning);
598
+ try {
599
+ switchTarget = await git(
600
+ repoRoot,
601
+ 'rev-parse',
602
+ '--verify',
603
+ '--end-of-options',
604
+ `${localRef}^{commit}`,
605
+ );
606
+ } catch {
607
+ throw new Error(`local source.ref "${localRef}" cannot be interpreted as a commit`);
608
+ }
609
+ }
571
610
  } else {
572
611
  try {
573
612
  await git(repoRoot, 'fetch', remote, branch);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {