@vzn/vx 0.0.465 → 0.0.466

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx",
3
- "version": "0.0.465",
3
+ "version": "0.0.466",
4
4
  "description": "The fastest task runner and build cache for JavaScript monorepos.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,10 +21,10 @@
21
21
  "node": ">=18"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@vzn/vx-linux-x64": "0.0.465",
25
- "@vzn/vx-linux-arm64": "0.0.465",
26
- "@vzn/vx-darwin-x64": "0.0.465",
27
- "@vzn/vx-darwin-arm64": "0.0.465"
24
+ "@vzn/vx-linux-x64": "0.0.466",
25
+ "@vzn/vx-linux-arm64": "0.0.466",
26
+ "@vzn/vx-darwin-x64": "0.0.466",
27
+ "@vzn/vx-darwin-arm64": "0.0.466"
28
28
  },
29
29
  "dependencies": {
30
30
  "@anthropic-ai/sandbox-runtime": "^0.0.76"
@@ -151,7 +151,6 @@ export async function affectedProjects(args: AffectedArgs): Promise<Set<string>>
151
151
  `("${since.slice(0, range) || 'HEAD'}"); vx diffs it against the working tree.`,
152
152
  )
153
153
  }
154
- await verifyRef(args.workspaceRoot, since)
155
154
  // Diff from the MERGE BASE of `since` and HEAD, not from `since` itself:
156
155
  // on a branch whose base has moved on, `git diff <base>` reports every
157
156
  // file OTHER people changed on the base (over-selection that defeats a
@@ -160,7 +159,9 @@ export async function affectedProjects(args: AffectedArgs): Promise<Set<string>>
160
159
  // when there is none (unrelated histories, a detached probe) the ref
161
160
  // itself is the base, as before. Turbo's two-dot range `A..HEAD` is the
162
161
  // one form that diffs from A itself.
163
- const base = fromMergeBase ? await mergeBase(args.workspaceRoot, since) : since
162
+ const base = fromMergeBase
163
+ ? await mergeBase(args.workspaceRoot, since)
164
+ : (await verifyRef(args.workspaceRoot, since), since)
164
165
 
165
166
  const [diffed, untracked] = await Promise.all([
166
167
  // `--no-renames` is crucial for project-affected detection: with
@@ -693,7 +694,13 @@ const resolvedRefs = new Map<string, string>()
693
694
  /** A ref that names an ancestor of HEAD by its own spelling (`HEAD~1`, `HEAD^`). */
694
695
  const HEAD_ANCESTOR = /^HEAD(?:~\d*|\^\d*)+$/
695
696
 
696
- /** `git merge-base <ref> HEAD`, or `ref` itself when the two share no ancestor. */
697
+ /**
698
+ * `git merge-base <ref> HEAD`, or `ref` itself when the two share no
699
+ * ancestor. A merge base proves the ref resolves, so `verifyRef`'s own
700
+ * spawn (synchronous, ~3.5 ms) runs only when there is none: to refuse a
701
+ * ref that does not resolve, or to pass one that does (exit 1, unrelated
702
+ * histories; a tree).
703
+ */
697
704
  async function mergeBase(workspaceRoot: string, ref: string): Promise<string> {
698
705
  // HEAD's own ancestor is its merge base with HEAD: the commit it names,
699
706
  // which the default base's search already resolved (`HEAD~1`).
@@ -702,7 +709,9 @@ async function mergeBase(workspaceRoot: string, ref: string): Promise<string> {
702
709
  const proc = spawnGit(['merge-base', '--end-of-options', ref, 'HEAD'], workspaceRoot)
703
710
  const [out, exit] = await Promise.all([new Response(proc.stdout).text(), proc.exited])
704
711
  const sha = out.trim()
705
- return exit === 0 && sha.length > 0 ? sha : ref
712
+ if (exit === 0 && sha.length > 0) return sha
713
+ await verifyRef(workspaceRoot, ref)
714
+ return ref
706
715
  }
707
716
 
708
717
  async function verifyRef(workspaceRoot: string, ref: string): Promise<void> {