@futurelastic/colab-handbook 1.14.1-rc.7 → 1.14.1-rc.9
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 +1 -1
- package/tools/colab +53 -2
- package/tools/lib/release-tag.js +8 -3
- package/tools/lib/squash.js +58 -2
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -1311,7 +1311,8 @@ Refuses, naming each failed condition (all are reported, not just the first):
|
|
|
1311
1311
|
judgement on the diff
|
|
1312
1312
|
switch-dependencies a colab:switch marker is malformed, or a finished switch needs one that is not
|
|
1313
1313
|
manifest-version the tag does not equal the version a manifest declares (VERSION, package.json,
|
|
1314
|
-
Cargo.toml [package],
|
|
1314
|
+
Cargo.toml [package], else [workspace.package] (#620), pyproject.toml
|
|
1315
|
+
[project]/[tool.poetry]) — none declared
|
|
1315
1316
|
passes: the tag is the version (#424). Under release.version-source: tag (#438;
|
|
1316
1317
|
the default where the machine cuts the tag, #484) a differing manifest is DERIVABLE — skipped, named in the tag message, and
|
|
1317
1318
|
stamped from the tag by the repo's own release step (never on trunk)
|
|
@@ -10555,7 +10556,7 @@ function branchCommits(mainRoot, trunk, branchName) {
|
|
|
10555
10556
|
const base = mb.ok && mb.stdout ? mb.stdout : trunk;
|
|
10556
10557
|
const logShas = git.git(['log', '--first-parent', `${base}..${branch}`, '--no-merges', '--format=%H'], mainRoot);
|
|
10557
10558
|
const shas = logShas.ok ? logShas.stdout.split('\n').filter(Boolean) : [];
|
|
10558
|
-
|
|
10559
|
+
const commits = shas.map((sha) => {
|
|
10559
10560
|
const full = git.git(['log', '-1', '--format=%B', sha], mainRoot).stdout;
|
|
10560
10561
|
const nl = full.indexOf('\n');
|
|
10561
10562
|
return {
|
|
@@ -10564,6 +10565,56 @@ function branchCommits(mainRoot, trunk, branchName) {
|
|
|
10564
10565
|
body: (nl === -1 ? '' : full.slice(nl + 1)).replace(/^\n+/, '').replace(/\s+$/, ''),
|
|
10565
10566
|
};
|
|
10566
10567
|
});
|
|
10568
|
+
markFollowUps(mainRoot, base, commits);
|
|
10569
|
+
return commits;
|
|
10570
|
+
}
|
|
10571
|
+
|
|
10572
|
+
/**
|
|
10573
|
+
* #621: flag each commit that only rewrites lines an EARLIER commit on this branch added — lines
|
|
10574
|
+
* absent from the merge base — as `followUp: true`, which lib/squash.js ranks below every named type.
|
|
10575
|
+
* Measured, never inferred from the subject: a one-word `fix:` to a `refactor:`'s brand-new text once
|
|
10576
|
+
* titled a 148-file unit, because `fix` outweighs `refactor`.
|
|
10577
|
+
*
|
|
10578
|
+
* Only a commit that could actually steal the subject is measured — one weighing MORE than every
|
|
10579
|
+
* older commit (a tie already goes to the oldest), so the cost is a diff plus a blame per hunk of a
|
|
10580
|
+
* handful of commits, not of the branch. Every uncertainty reads as "not a follow-up", leaving the
|
|
10581
|
+
* pre-#621 ranking in place. Per changed file of the candidate commit:
|
|
10582
|
+
* - a file this commit creates → not contained (new content, not a repair);
|
|
10583
|
+
* - a file absent at the base but present in the parent → wholly branch-added, contained;
|
|
10584
|
+
* - a file present at the base → every hunk must REPLACE or DELETE lines (a pure insertion adds
|
|
10585
|
+
* behaviour beside trunk's lines, so it is not contained) and `git blame base..<sha>^` must
|
|
10586
|
+
* attribute every replaced line to a commit of this branch (a boundary line is trunk's);
|
|
10587
|
+
* - binary, quoted-path or unparseable diffs, and any failed git read → not contained.
|
|
10588
|
+
*/
|
|
10589
|
+
function markFollowUps(mainRoot, base, commits) {
|
|
10590
|
+
if (!base || commits.length < 2) return;
|
|
10591
|
+
const own = new Set(commits.map((c) => c.sha));
|
|
10592
|
+
for (let i = commits.length - 2; i >= 0; i--) { // newest-first list; the oldest can never be one
|
|
10593
|
+
const c = commits[i];
|
|
10594
|
+
if (squash.isSyncNoise(c.subject)) continue;
|
|
10595
|
+
const older = commits.slice(i + 1).filter((o) => !squash.isSyncNoise(o.subject));
|
|
10596
|
+
if (!older.length || squash.commitWeight(c) <= Math.max(...older.map((o) => squash.commitWeight(o)))) continue;
|
|
10597
|
+
if (commitIsFollowUp(mainRoot, base, c.sha, own)) c.followUp = true;
|
|
10598
|
+
}
|
|
10599
|
+
}
|
|
10600
|
+
|
|
10601
|
+
function commitIsFollowUp(mainRoot, base, sha, own) {
|
|
10602
|
+
const d = git.git(['-c', 'core.quotePath=true', 'diff', '-U0', '--no-renames', '--no-ext-diff', '--no-color', `${sha}^`, sha], mainRoot);
|
|
10603
|
+
if (!d.ok) return false;
|
|
10604
|
+
const files = squash.parseZeroContextDiff(d.stdout);
|
|
10605
|
+
if (!files.length) return false;
|
|
10606
|
+
for (const f of files) {
|
|
10607
|
+
if (f.binary || f.unparsed || f.created || !f.path || !f.hunks.length) return false;
|
|
10608
|
+
if (!git.git(['cat-file', '-e', `${base}:${f.path}`], mainRoot).ok) continue; // the branch made this file
|
|
10609
|
+
for (const h of f.hunks) {
|
|
10610
|
+
if (h.oldCount === 0) return false;
|
|
10611
|
+
const b = git.git(['blame', '--porcelain', '-L', `${h.oldStart},+${h.oldCount}`, `${base}..${sha}^`, '--', f.path], mainRoot);
|
|
10612
|
+
if (!b.ok) return false;
|
|
10613
|
+
const authors = b.stdout.split('\n').map((l) => /^([0-9a-f]{40}) \d+ \d+/.exec(l)).filter(Boolean).map((m) => m[1]);
|
|
10614
|
+
if (!authors.length || authors.some((a) => !own.has(a))) return false;
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
return true;
|
|
10567
10618
|
}
|
|
10568
10619
|
|
|
10569
10620
|
/** Files one commit touched (#88's narrow-subject signal). [] when the read fails — never a guess. */
|
package/tools/lib/release-tag.js
CHANGED
|
@@ -176,10 +176,15 @@ function manifestVersions(readFile) {
|
|
|
176
176
|
if (j && typeof j.version === 'string') out.push({ file, version: j.version });
|
|
177
177
|
else if (j && j.version !== undefined) out.push({ file, error: `package.json version is ${JSON.stringify(j.version)}, not a string` });
|
|
178
178
|
} else if (file === 'Cargo.toml') {
|
|
179
|
+
// #620: a workspace root states the shared version in [workspace.package] — the form Cargo
|
|
180
|
+
// documents — and may have no [package] at all, or one that inherits it with
|
|
181
|
+
// version.workspace = true. Either way that is the version this repo releases. A literal
|
|
182
|
+
// [package] version still wins: [workspace.package] is only what members inherit.
|
|
179
183
|
const v = tomlTableVersion(text, 'package');
|
|
180
|
-
if (!v) continue;
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
if (v && !v.workspace) { if (v.value !== undefined) out.push({ file, version: v.value }); continue; }
|
|
185
|
+
const ws = tomlTableVersion(text, 'workspace.package');
|
|
186
|
+
if (ws && ws.value !== undefined) out.push({ file, version: ws.value });
|
|
187
|
+
else if (v && v.workspace) out.push({ file, error: 'Cargo.toml takes version.workspace = true but declares no [workspace.package] version — this is a member crate, and its workspace root is not read here' });
|
|
183
188
|
} else if (file === 'pyproject.toml') {
|
|
184
189
|
const v = tomlTableVersion(text, 'project') || tomlTableVersion(text, 'tool.poetry');
|
|
185
190
|
if (!v) continue;
|
package/tools/lib/squash.js
CHANGED
|
@@ -66,6 +66,19 @@ const TYPE_WEIGHT = {
|
|
|
66
66
|
*/
|
|
67
67
|
const UNRECOGNISED_WEIGHT = 5;
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Weight of a FOLLOW-UP (#621): a commit whose every changed line was added by an EARLIER commit on
|
|
71
|
+
* the same branch and is absent from the merge base. It repairs the branch's own unshipped work, so
|
|
72
|
+
* whatever its type says, it means nothing to a consumer — no shipped behaviour was broken. Measured
|
|
73
|
+
* at v1.14.0: a 148-file `refactor:` shipped titled by a one-word `fix:` to text that refactor had
|
|
74
|
+
* just added, because `fix` (60) outweighs `refactor` (40). Ranked below every named type AND below
|
|
75
|
+
* `UNRECOGNISED_WEIGHT`, so it never titles a unit that has any other shaped commit; above 0 only so
|
|
76
|
+
* a branch of nothing but follow-ups and shapeless commits still reads as "weighed". The flag itself
|
|
77
|
+
* (`commit.followUp`) is measured by the CLI against git (`tools/colab` `markFollowUps`) — this
|
|
78
|
+
* module stays pure and only reads it.
|
|
79
|
+
*/
|
|
80
|
+
const FOLLOW_UP_WEIGHT = 3;
|
|
81
|
+
|
|
69
82
|
/** A breaking change outranks every non-breaking one, whatever its type. */
|
|
70
83
|
const BREAKING_BONUS = 1000;
|
|
71
84
|
|
|
@@ -105,6 +118,9 @@ function commitWeight(commit) {
|
|
|
105
118
|
if (!parsed) return 0;
|
|
106
119
|
const base = TYPE_WEIGHT[parsed.type];
|
|
107
120
|
const breaking = parsed.breaking || /^BREAKING[ -]CHANGE:/m.test(String((commit && commit.body) || ''));
|
|
121
|
+
// #621: a follow-up keeps its breaking bonus — declaring a break is a consumer-facing claim, not a
|
|
122
|
+
// repair — but loses its type's rank.
|
|
123
|
+
if (commit && commit.followUp) return FOLLOW_UP_WEIGHT + (breaking ? BREAKING_BONUS : 0);
|
|
108
124
|
if (base === undefined) return UNRECOGNISED_WEIGHT + (breaking ? BREAKING_BONUS : 0); // shaped, unnamed type (#261)
|
|
109
125
|
return base + (breaking ? BREAKING_BONUS : 0);
|
|
110
126
|
}
|
|
@@ -153,7 +169,8 @@ function unweightedCommits(commits) {
|
|
|
153
169
|
* Rules, in order:
|
|
154
170
|
* 1. sync-merge noise never titles a squash (unless it is all there is);
|
|
155
171
|
* 2. highest weight wins — an unrecognised-but-shaped type (#261, weight `UNRECOGNISED_WEIGHT`)
|
|
156
|
-
* beats a truly shapeless commit here, so it is no longer a coin-flip against rule 4;
|
|
172
|
+
* beats a truly shapeless commit here, so it is no longer a coin-flip against rule 4; a
|
|
173
|
+
* follow-up to the branch's own unshipped lines (#621, `FOLLOW_UP_WEIGHT`) ranks below both;
|
|
157
174
|
* 3. ties go to the OLDEST of the tied commits — on a branch of three `feat`s, the first one
|
|
158
175
|
* names the branch's purpose and the rest extend it;
|
|
159
176
|
* 4. if NOTHING on the branch carries any Conventional Commit shape at all (weight 0, the one
|
|
@@ -507,8 +524,47 @@ function spliceCloses(message, closes = [], refs = [], conflicts) {
|
|
|
507
524
|
return rest ? `${head}\n\n${refLine}\n\n${rest}` : `${head}\n\n${refLine}`;
|
|
508
525
|
}
|
|
509
526
|
|
|
527
|
+
/**
|
|
528
|
+
* Parse `git diff -U0 --no-renames` output into per-file records for the #621 follow-up measurement:
|
|
529
|
+
* `{ path, created, deleted, binary, unparsed, hunks: [{ oldStart, oldCount }] }`. `created` means
|
|
530
|
+
* the old side is /dev/null — the commit added the file. `unparsed` is set when a path is quoted
|
|
531
|
+
* (git's C-style escaping) — the caller must then refuse to call the commit a follow-up rather than
|
|
532
|
+
* guess at the name. Pure, so the hunk arithmetic is testable without a repository.
|
|
533
|
+
*/
|
|
534
|
+
function parseZeroContextDiff(diffText) {
|
|
535
|
+
const files = [];
|
|
536
|
+
let cur = null;
|
|
537
|
+
const strip = (p) => p.replace(/\t$/, '');
|
|
538
|
+
for (const line of String(diffText || '').split('\n')) {
|
|
539
|
+
if (line.startsWith('diff --git ')) {
|
|
540
|
+
cur = { path: null, created: false, deleted: false, binary: false, unparsed: false, hunks: [] };
|
|
541
|
+
files.push(cur);
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (!cur) continue;
|
|
545
|
+
if (line.startsWith('--- ')) {
|
|
546
|
+
const p = strip(line.slice(4));
|
|
547
|
+
if (p === '/dev/null') cur.created = true;
|
|
548
|
+
else if (p.startsWith('"')) cur.unparsed = true;
|
|
549
|
+
else if (p.startsWith('a/')) cur.path = p.slice(2);
|
|
550
|
+
else cur.unparsed = true;
|
|
551
|
+
} else if (line.startsWith('+++ ')) {
|
|
552
|
+
const p = strip(line.slice(4));
|
|
553
|
+
if (p === '/dev/null') cur.deleted = true;
|
|
554
|
+
else if (p.startsWith('"')) cur.unparsed = true;
|
|
555
|
+
} else if (line.startsWith('Binary files ') || line === 'GIT binary patch') {
|
|
556
|
+
cur.binary = true;
|
|
557
|
+
} else if (line.startsWith('@@ ')) {
|
|
558
|
+
const m = /^@@ -(\d+)(?:,(\d+))? \+\d+(?:,\d+)? @@/.exec(line);
|
|
559
|
+
if (!m) { cur.unparsed = true; continue; }
|
|
560
|
+
cur.hunks.push({ oldStart: Number(m[1]), oldCount: m[2] === undefined ? 1 : Number(m[2]) });
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return files;
|
|
564
|
+
}
|
|
565
|
+
|
|
510
566
|
module.exports = {
|
|
511
|
-
TYPE_WEIGHT, UNRECOGNISED_WEIGHT, BREAKING_BONUS, TRAILER_RE,
|
|
567
|
+
TYPE_WEIGHT, UNRECOGNISED_WEIGHT, FOLLOW_UP_WEIGHT, BREAKING_BONUS, TRAILER_RE, parseZeroContextDiff,
|
|
512
568
|
isSyncNoise, parseSubject, commitWeight, hasRecognisedType, unweightedCommits, pickSubjectIndex,
|
|
513
569
|
harvestTrailers, composeSquashMessage, spliceCloses, reconcileClosesRefsConflict,
|
|
514
570
|
closedIssueNumbers, inheritedClosingKeywordConflicts,
|