@futurelastic/colab-handbook 1.13.0-rc.29 → 1.13.0-rc.30

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tools/colab +24 -4
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
36
- "version": "1.13.0-rc.29"
36
+ "version": "1.13.0-rc.30"
37
37
  }
package/tools/colab CHANGED
@@ -3917,12 +3917,26 @@ function migrationGrantReviewRecord(repoAbs, opts) {
3917
3917
  // #508: bind what was reviewed — the branch's migration files at the tip, by content. Same path
3918
3918
  // rule the ship gate fires on (newMigrations), against origin's trunk. A branch with no migration
3919
3919
  // to review gets no id and stays HEAD-bound.
3920
+ //
3921
+ // #563: and never silently fall back to HEAD binding. A grant posted without `migrations:` for a
3922
+ // branch that HAS migrations is voided by the very trunk sync ship demands — the cost #508 removed.
3923
+ // So every way this can fail to answer refuses instead: no trunk to diff against, a diff git
3924
+ // cannot compute (base or tip object missing here), or a tree it cannot read at the tip.
3920
3925
  const trunk = resolveTrunk(repoAbs, projectDoc(repoAbs));
3926
+ if (!trunk) {
3927
+ throw new UserError("cannot resolve this repo's trunk from project.yml — a reviewer grant binds the branch's migration content against trunk, so nothing was posted. Declare `trunk:` in .github/project.yml, then re-run `colab migration-grant`");
3928
+ }
3921
3929
  const remote = git.remoteInfo(repoAbs).name || 'origin';
3922
- let base = trunk ? `${remote}/${trunk}` : null;
3923
- if (base && !git.git(['rev-parse', '--verify', '--quiet', `${base}^{commit}`], repoAbs).ok) base = trunk;
3924
- const migrations = base ? newMigrations(repoAbs, base, tip) : [];
3930
+ let base = `${remote}/${trunk}`;
3931
+ if (!git.git(['rev-parse', '--verify', '--quiet', `${base}^{commit}`], repoAbs).ok) base = trunk;
3932
+ const migrations = newMigrationsOrNull(repoAbs, base, tip);
3933
+ if (migrations === null) {
3934
+ throw new UserError(`cannot list "${opts.branch}"'s files against ${base} (git diff ${base}...${tip.slice(0, 12)} failed) — without that list the grant could not bind the migration content and would be voided by the next trunk sync; nothing was posted. Run \`git fetch ${remote} ${trunk} ${opts.branch}\`, then re-run \`colab migration-grant\``);
3935
+ }
3925
3936
  const contentId = migrationContentAt(repoAbs, migrations, tip);
3937
+ if (migrations.length > 0 && !contentId) {
3938
+ throw new UserError(`"${opts.branch}" carries ${migrations.length} migration file(s) (${migrations.join(', ')}) but their content id could not be computed at ${tip.slice(0, 12)} (git ls-tree failed) — a grant without it binds the HEAD alone and the next trunk sync voids it; nothing was posted. Run \`git fetch ${remote} ${opts.branch}\`, then re-run \`colab migration-grant\``);
3939
+ }
3926
3940
 
3927
3941
  const rec = {
3928
3942
  v: '1', role, reviewer: opts.reviewer, head: tip,
@@ -9938,8 +9952,14 @@ function trustAt(repoAbs, ref) {
9938
9952
  * gated by it, and a branch that deletes trunk's declaration is still gated by trunk's.
9939
9953
  */
9940
9954
  function newMigrations(mainRoot, trunk, branch) {
9955
+ return newMigrationsOrNull(mainRoot, trunk, branch) || [];
9956
+ }
9957
+
9958
+ /** newMigrations, but null — not [] — when git cannot compute the diff (#563): the grant write path
9959
+ * must tell "no migrations" from "could not look", and refuses on the second. */
9960
+ function newMigrationsOrNull(mainRoot, trunk, branch) {
9941
9961
  const r = git.git(['diff', '--name-only', `${trunk}...${branch}`], mainRoot);
9942
- if (!r.ok) return [];
9962
+ if (!r.ok) return null;
9943
9963
  const declared = migrationPaths.unionPaths(projectDoc(mainRoot), projectDocAt(mainRoot, trunk), projectDocAt(mainRoot, branch));
9944
9964
  return r.stdout.split('\n').filter(Boolean).filter((f) => migrationPaths.isMigrationPath(f, declared));
9945
9965
  }