@nzyme/cli 0.14.0 → 0.15.1
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/bin/cli.js +3 -0
- package/dist/Command.d.ts +48 -5
- package/dist/Command.js +69 -6
- package/dist/Command.js.map +1 -1
- package/dist/Command.test.d.ts +1 -0
- package/dist/Command.test.js +77 -0
- package/dist/Command.test.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +23 -3
- package/dist/cli.js.map +1 -1
- package/dist/codeIndex/IndexSettings.d.ts +60 -0
- package/dist/codeIndex/IndexSettings.js +59 -0
- package/dist/codeIndex/IndexSettings.js.map +1 -0
- package/dist/codeIndex/IndexSymbol.d.ts +32 -0
- package/dist/codeIndex/IndexSymbol.js +2 -0
- package/dist/codeIndex/IndexSymbol.js.map +1 -0
- package/dist/codeIndex/NzymeIndexConfig.d.ts +72 -0
- package/dist/codeIndex/NzymeIndexConfig.js +101 -0
- package/dist/codeIndex/NzymeIndexConfig.js.map +1 -0
- package/dist/codeIndex/NzymeIndexConfig.test.d.ts +1 -0
- package/dist/codeIndex/NzymeIndexConfig.test.js +56 -0
- package/dist/codeIndex/NzymeIndexConfig.test.js.map +1 -0
- package/dist/codeIndex/collectIndexSourceFiles.d.ts +8 -0
- package/dist/codeIndex/collectIndexSourceFiles.js +57 -0
- package/dist/codeIndex/collectIndexSourceFiles.js.map +1 -0
- package/dist/codeIndex/collectSymbols.d.ts +27 -0
- package/dist/codeIndex/collectSymbols.js +151 -0
- package/dist/codeIndex/collectSymbols.js.map +1 -0
- package/dist/codeIndex/collectSymbols.test.d.ts +1 -0
- package/dist/codeIndex/collectSymbols.test.js +204 -0
- package/dist/codeIndex/collectSymbols.test.js.map +1 -0
- package/dist/codeIndex/extractComponent.d.ts +25 -0
- package/dist/codeIndex/extractComponent.js +38 -0
- package/dist/codeIndex/extractComponent.js.map +1 -0
- package/dist/codeIndex/extractComponent.test.d.ts +1 -0
- package/dist/codeIndex/extractComponent.test.js +65 -0
- package/dist/codeIndex/extractComponent.test.js.map +1 -0
- package/dist/codeIndex/extractDefineSymbol.d.ts +30 -0
- package/dist/codeIndex/extractDefineSymbol.js +86 -0
- package/dist/codeIndex/extractDefineSymbol.js.map +1 -0
- package/dist/codeIndex/extractDefineSymbol.test.d.ts +1 -0
- package/dist/codeIndex/extractDefineSymbol.test.js +142 -0
- package/dist/codeIndex/extractDefineSymbol.test.js.map +1 -0
- package/dist/codeIndex/extractEntity.d.ts +29 -0
- package/dist/codeIndex/extractEntity.js +63 -0
- package/dist/codeIndex/extractEntity.js.map +1 -0
- package/dist/codeIndex/extractEntity.test.d.ts +1 -0
- package/dist/codeIndex/extractEntity.test.js +79 -0
- package/dist/codeIndex/extractEntity.test.js.map +1 -0
- package/dist/codeIndex/extractUtil.d.ts +27 -0
- package/dist/codeIndex/extractUtil.js +98 -0
- package/dist/codeIndex/extractUtil.js.map +1 -0
- package/dist/codeIndex/extractUtil.test.d.ts +1 -0
- package/dist/codeIndex/extractUtil.test.js +111 -0
- package/dist/codeIndex/extractUtil.test.js.map +1 -0
- package/dist/codeIndex/importPathOf.d.ts +18 -0
- package/dist/codeIndex/importPathOf.js +17 -0
- package/dist/codeIndex/importPathOf.js.map +1 -0
- package/dist/codeIndex/importPathOf.test.d.ts +1 -0
- package/dist/codeIndex/importPathOf.test.js +40 -0
- package/dist/codeIndex/importPathOf.test.js.map +1 -0
- package/dist/codeIndex/jsdocSummary.d.ts +9 -0
- package/dist/codeIndex/jsdocSummary.js +18 -0
- package/dist/codeIndex/jsdocSummary.js.map +1 -0
- package/dist/codeIndex/jsdocSummary.test.d.ts +1 -0
- package/dist/codeIndex/jsdocSummary.test.js +33 -0
- package/dist/codeIndex/jsdocSummary.test.js.map +1 -0
- package/dist/codeIndex/renderMarkdown.d.ts +27 -0
- package/dist/codeIndex/renderMarkdown.js +171 -0
- package/dist/codeIndex/renderMarkdown.js.map +1 -0
- package/dist/codeIndex/renderMarkdown.test.d.ts +1 -0
- package/dist/codeIndex/renderMarkdown.test.js +291 -0
- package/dist/codeIndex/renderMarkdown.test.js.map +1 -0
- package/dist/commands/DepcheckCommand.d.ts +17 -0
- package/dist/commands/DepcheckCommand.js +229 -42
- package/dist/commands/DepcheckCommand.js.map +1 -1
- package/dist/commands/FormatMarkdownCommand.d.ts +22 -0
- package/dist/commands/FormatMarkdownCommand.js +256 -0
- package/dist/commands/FormatMarkdownCommand.js.map +1 -0
- package/dist/commands/FormatMarkdownCommand.test.d.ts +1 -0
- package/dist/commands/FormatMarkdownCommand.test.js +82 -0
- package/dist/commands/FormatMarkdownCommand.test.js.map +1 -0
- package/dist/commands/IndexCommand.d.ts +20 -0
- package/dist/commands/IndexCommand.js +81 -0
- package/dist/commands/IndexCommand.js.map +1 -0
- package/dist/commands/IndexCommand.test.d.ts +1 -0
- package/dist/commands/IndexCommand.test.js +126 -0
- package/dist/commands/IndexCommand.test.js.map +1 -0
- package/dist/commands/LocaliseCommand.d.ts +23 -0
- package/dist/commands/LocaliseCommand.js +125 -0
- package/dist/commands/LocaliseCommand.js.map +1 -0
- package/dist/commands/MonorepoCommand.d.ts +14 -0
- package/dist/commands/MonorepoCommand.js +243 -144
- package/dist/commands/MonorepoCommand.js.map +1 -1
- package/dist/commands/QuietRunCommand.d.ts +27 -0
- package/dist/commands/QuietRunCommand.js +140 -0
- package/dist/commands/QuietRunCommand.js.map +1 -0
- package/dist/commands/QuietRunCommand.test.d.ts +1 -0
- package/dist/commands/QuietRunCommand.test.js +48 -0
- package/dist/commands/QuietRunCommand.test.js.map +1 -0
- package/dist/commands/SubmoduleBumpCommand.d.ts +27 -0
- package/dist/commands/SubmoduleBumpCommand.js +77 -0
- package/dist/commands/SubmoduleBumpCommand.js.map +1 -0
- package/dist/execute.d.ts +7 -2
- package/dist/execute.js +4 -2
- package/dist/execute.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/initialize.d.ts +1 -15
- package/dist/initialize.js +4 -8
- package/dist/initialize.js.map +1 -1
- package/dist/quietRun/quietRunReport.d.ts +70 -0
- package/dist/quietRun/quietRunReport.js +128 -0
- package/dist/quietRun/quietRunReport.js.map +1 -0
- package/dist/quietRun/quietRunReport.test.d.ts +1 -0
- package/dist/quietRun/quietRunReport.test.js +87 -0
- package/dist/quietRun/quietRunReport.test.js.map +1 -0
- package/dist/submodule/GitRepository.d.ts +70 -0
- package/dist/submodule/GitRepository.js +129 -0
- package/dist/submodule/GitRepository.js.map +1 -0
- package/dist/submodule/bumpSubmodule.d.ts +45 -0
- package/dist/submodule/bumpSubmodule.js +52 -0
- package/dist/submodule/bumpSubmodule.js.map +1 -0
- package/dist/submodule/renderBumpSummary.d.ts +12 -0
- package/dist/submodule/renderBumpSummary.js +50 -0
- package/dist/submodule/renderBumpSummary.js.map +1 -0
- package/dist/submodule/renderBumpSummary.test.d.ts +1 -0
- package/dist/submodule/renderBumpSummary.test.js +55 -0
- package/dist/submodule/renderBumpSummary.test.js.map +1 -0
- package/dist/submodule/submodule.test.d.ts +1 -0
- package/dist/submodule/submodule.test.js +155 -0
- package/dist/submodule/submodule.test.js.map +1 -0
- package/package.json +55 -50
- package/dist/commands/BuildCommand.d.ts +0 -15
- package/dist/commands/BuildCommand.js +0 -49
- package/dist/commands/BuildCommand.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-emitted failure markers. Language-agnostic: they cover tsc (`TSxxxx`), test runners, nx,
|
|
3
|
+
* playwright and generic shell errors. Broad on purpose — on a failing run some noise beats missing
|
|
4
|
+
* the real cause. Case-insensitive, like the `grep -i` it replaces.
|
|
5
|
+
*/
|
|
6
|
+
const ERROR_SIGNATURE = /(\berror\b|\bfail(ed|ure|ing)?\b|\bassert|\bexception\b|\bcannot\b|not found|unexpected|\bTS[0-9]{3,}\b|✗|✕|✖|✘|✱|›)/i;
|
|
7
|
+
/** What bun prints, and exits 0 with, when `bun run` gets a script or file it does not know. */
|
|
8
|
+
const BUN_USAGE_BANNER = 'Usage: bun run';
|
|
9
|
+
/**
|
|
10
|
+
* Turns a finished run into the little that should reach a coding agent's context: one line on
|
|
11
|
+
* success; on failure the error-looking lines, a bounded tail and the log path. Kept pure so the
|
|
12
|
+
* exact output format — which agents learn to read — is pinned by tests.
|
|
13
|
+
*
|
|
14
|
+
* The exit code is passed through, with one exception: a bun usage banner on an otherwise
|
|
15
|
+
* successful run is reported as a failure with exit code 1 (see {@link getBunUsageBanner}).
|
|
16
|
+
* @__NO_SIDE_EFFECTS__
|
|
17
|
+
*/
|
|
18
|
+
export function renderQuietRunReport(options) {
|
|
19
|
+
const { label, logPath, exitCode, seconds, log, tailCount, maxMatches } = options;
|
|
20
|
+
const lineCount = countLines(log);
|
|
21
|
+
if (exitCode === 0) {
|
|
22
|
+
const banner = getBunUsageBanner(log);
|
|
23
|
+
if (banner !== null) {
|
|
24
|
+
return {
|
|
25
|
+
exitCode: 1,
|
|
26
|
+
stdout: '',
|
|
27
|
+
stderr: `✗ FAILED (bun usage banner — invalid invocation exited 0 without running anything) · ${label} · full log: ${logPath}\n` +
|
|
28
|
+
` first output line: ${banner}\n`,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
exitCode: 0,
|
|
33
|
+
stdout: `✓ passed · ${label} · ${lineCount} lines · ${seconds}s · full log: ${logPath}\n`,
|
|
34
|
+
stderr: '',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const errorLines = extractErrorLines(log, maxMatches);
|
|
38
|
+
const lines = [
|
|
39
|
+
`✗ FAILED (exit ${exitCode}) · ${label} · ${lineCount} lines · ${seconds}s · full log: ${logPath}`,
|
|
40
|
+
'--- error-signature lines (grep) ---',
|
|
41
|
+
...(errorLines.length > 0 ? errorLines : ['(no matching error lines — read the tail / full log below)']),
|
|
42
|
+
`--- last ${tailCount} lines ---`,
|
|
43
|
+
...getTailLines(log, tailCount),
|
|
44
|
+
`--- full log: ${logPath} (read selectively; do not re-dump it whole) ---`,
|
|
45
|
+
];
|
|
46
|
+
return { exitCode, stdout: `${lines.join('\n')}\n`, stderr: '' };
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the lines of a log that look like errors, prefixed with their 1-based line number
|
|
50
|
+
* (`12:error TS2322: …`, as `grep -n` prints them), at most `maxMatches` of them. Counting stops at
|
|
51
|
+
* the limit rather than truncating afterwards, so an empty result reliably means "no error lines at
|
|
52
|
+
* all", never "too many to show".
|
|
53
|
+
* @__NO_SIDE_EFFECTS__
|
|
54
|
+
*/
|
|
55
|
+
export function extractErrorLines(log, maxMatches) {
|
|
56
|
+
const matches = [];
|
|
57
|
+
for (const [index, line] of splitLines(log).entries()) {
|
|
58
|
+
if (matches.length >= maxMatches) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
if (ERROR_SIGNATURE.test(line)) {
|
|
62
|
+
matches.push(`${index + 1}:${line}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return matches;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Detects bun's own usage banner, returning the banner line, or `null` when the log is not one.
|
|
69
|
+
*
|
|
70
|
+
* An invalid `bun … run …` invocation (e.g. a stale or renamed script name) prints bun's usage
|
|
71
|
+
* banner and exits 0 — a false green with no command actually run. Narrow on purpose: only the
|
|
72
|
+
* FIRST non-empty output line counts, so a later legitimate mention of `Usage: bun run` in real
|
|
73
|
+
* output cannot trip it.
|
|
74
|
+
* @__NO_SIDE_EFFECTS__
|
|
75
|
+
*/
|
|
76
|
+
export function getBunUsageBanner(log) {
|
|
77
|
+
for (const line of splitLines(log)) {
|
|
78
|
+
if (line.trim() === '') {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
return line.startsWith(BUN_USAGE_BANNER) ? line : null;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The log file name for a run: the command's first word made filename-safe, a local timestamp and
|
|
87
|
+
* the process id — e.g. `bun-20260102-030405-1234.log`. The timestamp keeps logs in run order; the
|
|
88
|
+
* pid keeps two runs started in the same second apart.
|
|
89
|
+
* @__NO_SIDE_EFFECTS__
|
|
90
|
+
*/
|
|
91
|
+
export function getQuietRunLogFileName(options) {
|
|
92
|
+
const { executable, date, pid } = options;
|
|
93
|
+
const slug = executable.replaceAll(/[^a-zA-Z0-9._-]/g, '-');
|
|
94
|
+
const day = `${date.getFullYear()}${pad(date.getMonth() + 1)}${pad(date.getDate())}`;
|
|
95
|
+
const time = `${pad(date.getHours())}${pad(date.getMinutes())}${pad(date.getSeconds())}`;
|
|
96
|
+
return `${slug}-${day}-${time}-${pid}.log`;
|
|
97
|
+
}
|
|
98
|
+
/** The last `count` lines of a log, as `tail -n` shows them. */
|
|
99
|
+
function getTailLines(log, count) {
|
|
100
|
+
const lines = splitLines(log);
|
|
101
|
+
return count > 0 ? lines.slice(-count) : [];
|
|
102
|
+
}
|
|
103
|
+
/** Number of lines, counted as `wc -l` does: newline characters. */
|
|
104
|
+
function countLines(log) {
|
|
105
|
+
let count = 0;
|
|
106
|
+
for (const char of log) {
|
|
107
|
+
if (char === '\n') {
|
|
108
|
+
count++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return count;
|
|
112
|
+
}
|
|
113
|
+
/** Splits a log into lines; the empty remainder after a final newline is not a line. */
|
|
114
|
+
function splitLines(log) {
|
|
115
|
+
if (log === '') {
|
|
116
|
+
return [];
|
|
117
|
+
}
|
|
118
|
+
const lines = log.split('\n');
|
|
119
|
+
if (lines.at(-1) === '') {
|
|
120
|
+
lines.pop();
|
|
121
|
+
}
|
|
122
|
+
return lines;
|
|
123
|
+
}
|
|
124
|
+
/** Zero-pads a date part to two digits. */
|
|
125
|
+
function pad(value) {
|
|
126
|
+
return String(value).padStart(2, '0');
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=quietRunReport.js.map
|
|
@@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,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QACtB,KAAK,CAAC,GAAG,EAAE,CAAC;IAChB,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,2CAA2C;AAC3C,SAAS,GAAG,CAAC,KAAa;IACtB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { extractErrorLines, getBunUsageBanner, getQuietRunLogFileName, renderQuietRunReport, } from './quietRunReport.js';
|
|
3
|
+
describe('extractErrorLines', () => {
|
|
4
|
+
test('returns error-looking lines prefixed with their 1-based line number', () => {
|
|
5
|
+
const log = [
|
|
6
|
+
'building…',
|
|
7
|
+
'src/a.ts(3,1): error TS2322: Type mismatch',
|
|
8
|
+
'all good here',
|
|
9
|
+
'Test FAILED: adds numbers',
|
|
10
|
+
'Cannot find module x',
|
|
11
|
+
'thing not found',
|
|
12
|
+
'Unexpected token',
|
|
13
|
+
'✗ broken',
|
|
14
|
+
'',
|
|
15
|
+
].join('\n');
|
|
16
|
+
expect(extractErrorLines(log, 40)).toEqual([
|
|
17
|
+
'2:src/a.ts(3,1): error TS2322: Type mismatch',
|
|
18
|
+
'4:Test FAILED: adds numbers',
|
|
19
|
+
'5:Cannot find module x',
|
|
20
|
+
'6:thing not found',
|
|
21
|
+
'7:Unexpected token',
|
|
22
|
+
'8:✗ broken',
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
test('matches whole words only where the signature says so', () => {
|
|
26
|
+
expect(extractErrorLines('errors: 0\nterrorist\nfailsafe\n', 40)).toEqual([]);
|
|
27
|
+
expect(extractErrorLines('ts1234 lowercase code\n', 40)).toEqual(['1:ts1234 lowercase code']);
|
|
28
|
+
});
|
|
29
|
+
test('stops at the limit', () => {
|
|
30
|
+
const log = 'error 1\nerror 2\nerror 3\n';
|
|
31
|
+
expect(extractErrorLines(log, 2)).toEqual(['1:error 1', '2:error 2']);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('getBunUsageBanner', () => {
|
|
35
|
+
test('detects the banner on the first non-empty line', () => {
|
|
36
|
+
expect(getBunUsageBanner('\n \nUsage: bun run [flags] <file or script>\nmore')).toBe('Usage: bun run [flags] <file or script>');
|
|
37
|
+
});
|
|
38
|
+
test('ignores a later mention of the banner', () => {
|
|
39
|
+
expect(getBunUsageBanner('real output\nUsage: bun run [flags]\n')).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
test('ignores an indented banner and an empty log', () => {
|
|
42
|
+
expect(getBunUsageBanner(' Usage: bun run\n')).toBeNull();
|
|
43
|
+
expect(getBunUsageBanner('')).toBeNull();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
describe('getQuietRunLogFileName', () => {
|
|
47
|
+
test('slugs the executable and stamps date and pid', () => {
|
|
48
|
+
const date = new Date(2026, 0, 2, 3, 4, 5);
|
|
49
|
+
expect(getQuietRunLogFileName({ executable: './scripts/build me.sh', date, pid: 42 })).toBe('.-scripts-build-me.sh-20260102-030405-42.log');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('renderQuietRunReport', () => {
|
|
53
|
+
const base = { label: 'bun test', logPath: '.context/cmd-logs/x.log', seconds: 3, tailCount: 2, maxMatches: 40 };
|
|
54
|
+
test('prints a single line on success', () => {
|
|
55
|
+
expect(renderQuietRunReport({ ...base, exitCode: 0, log: 'a\nb\n' })).toEqual({
|
|
56
|
+
exitCode: 0,
|
|
57
|
+
stdout: '✓ passed · bun test · 2 lines · 3s · full log: .context/cmd-logs/x.log\n',
|
|
58
|
+
stderr: '',
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
test('turns a bun usage banner with exit 0 into a failure', () => {
|
|
62
|
+
const report = renderQuietRunReport({ ...base, exitCode: 0, log: 'Usage: bun run [flags] <script>\n' });
|
|
63
|
+
expect(report.exitCode).toBe(1);
|
|
64
|
+
expect(report.stdout).toBe('');
|
|
65
|
+
expect(report.stderr).toBe('✗ FAILED (bun usage banner — invalid invocation exited 0 without running anything) · bun test · full log: .context/cmd-logs/x.log\n' +
|
|
66
|
+
' first output line: Usage: bun run [flags] <script>\n');
|
|
67
|
+
});
|
|
68
|
+
test('prints error lines, the tail and the log path on failure, passing the exit code through', () => {
|
|
69
|
+
const report = renderQuietRunReport({ ...base, exitCode: 3, log: 'one\nerror: two\nthree\n' });
|
|
70
|
+
expect(report.exitCode).toBe(3);
|
|
71
|
+
expect(report.stdout).toBe([
|
|
72
|
+
'✗ FAILED (exit 3) · bun test · 3 lines · 3s · full log: .context/cmd-logs/x.log',
|
|
73
|
+
'--- error-signature lines (grep) ---',
|
|
74
|
+
'2:error: two',
|
|
75
|
+
'--- last 2 lines ---',
|
|
76
|
+
'error: two',
|
|
77
|
+
'three',
|
|
78
|
+
'--- full log: .context/cmd-logs/x.log (read selectively; do not re-dump it whole) ---',
|
|
79
|
+
'',
|
|
80
|
+
].join('\n'));
|
|
81
|
+
});
|
|
82
|
+
test('says so when a failure has no error-looking lines', () => {
|
|
83
|
+
const report = renderQuietRunReport({ ...base, exitCode: 1, log: 'quiet\n' });
|
|
84
|
+
expect(report.stdout).toContain('(no matching error lines — read the tail / full log below)');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=quietRunReport.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quietRunReport.test.js","sourceRoot":"","sources":["../../src/quietRun/quietRunReport.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EACH,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,QAAQ,C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D,CAAC,CAAC;IAClG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** A commit as listed in a bump summary. */
|
|
2
|
+
export interface CommitSummary {
|
|
3
|
+
sha: string;
|
|
4
|
+
subject: string;
|
|
5
|
+
}
|
|
6
|
+
/** Outcome of a git invocation that is allowed to fail. */
|
|
7
|
+
export interface GitResult {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
exitCode: number;
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The small set of git plumbing the submodule commands are built from, bound to one working
|
|
15
|
+
* directory (the product repository or the submodule's clone inside it).
|
|
16
|
+
*
|
|
17
|
+
* Plain `git` through `execa` rather than a git library: every operation here is one command whose
|
|
18
|
+
* exit code is the answer (`merge-base --is-ancestor`, `rev-parse --verify`), and `@nzyme/cli`
|
|
19
|
+
* already depends on `execa`.
|
|
20
|
+
*/
|
|
21
|
+
export declare class GitRepository {
|
|
22
|
+
readonly dir: string;
|
|
23
|
+
constructor(dir: string);
|
|
24
|
+
/**
|
|
25
|
+
* The gitlink of a submodule path — the exact submodule commit the repository's `HEAD` pins.
|
|
26
|
+
*
|
|
27
|
+
* Read from the tree of `HEAD` rather than from the submodule's checkout: the commit is what the
|
|
28
|
+
* product's CI tested, while the checkout may have moved since. Throws when the path is not a
|
|
29
|
+
* submodule at `HEAD`, so a typo in `--path` cannot silently act on nothing.
|
|
30
|
+
*/
|
|
31
|
+
readGitlink(submodulePath: string): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Throws unless this directory is the top of a checked-out repository. An uninitialised
|
|
34
|
+
* submodule is an empty directory, and git run inside it would silently act on the parent
|
|
35
|
+
* repository instead.
|
|
36
|
+
*/
|
|
37
|
+
assertCheckedOut(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Makes the history deep enough for an ancestry check. A shallow clone (what CI checkouts make by
|
|
40
|
+
* default) cuts the parent links `merge-base --is-ancestor` walks, so a perfectly linear
|
|
41
|
+
* fast-forward would look like a divergence.
|
|
42
|
+
*/
|
|
43
|
+
ensureFullHistory(remote: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches a ref (branch, tag or full SHA) from the remote and returns the commit it resolves to,
|
|
46
|
+
* or `null` when the remote does not have it — so callers can fall back to a local lookup.
|
|
47
|
+
*/
|
|
48
|
+
fetchCommit(remote: string, ref: string): Promise<string | null>;
|
|
49
|
+
/** The commit a local revision resolves to (tags peeled), or `null` when it does not exist locally. */
|
|
50
|
+
resolveLocalCommit(revision: string): Promise<string | null>;
|
|
51
|
+
/** Commits reachable from `to` but not from `from`, newest first — `git log from..to`. */
|
|
52
|
+
listCommits(from: string, to: string): Promise<CommitSummary[]>;
|
|
53
|
+
/** Number of commits reachable from `to` but not from `from`. */
|
|
54
|
+
countCommits(from: string, to: string): Promise<number>;
|
|
55
|
+
/**
|
|
56
|
+
* The `https://github.com/<owner>/<repo>` URL of a remote, or `null` when it is not on GitHub.
|
|
57
|
+
*
|
|
58
|
+
* Reads the configured URL (not `remote get-url`, which applies `insteadOf` rewrites and so can
|
|
59
|
+
* return a URL with a token in it) and rebuilds it from owner and repo only — the result goes
|
|
60
|
+
* into a PR body, so nothing else from the URL may leak into it.
|
|
61
|
+
*/
|
|
62
|
+
getGitHubRepoUrl(remote: string): Promise<string | null>;
|
|
63
|
+
/** Runs git and returns its trimmed stdout; throws with git's stderr when it fails. */
|
|
64
|
+
git(args: string[]): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Runs git without throwing on a non-zero exit. Terminal prompts are disabled: in CI a missing
|
|
67
|
+
* credential must fail the step, not hang it until the job times out.
|
|
68
|
+
*/
|
|
69
|
+
tryGit(args: string[]): Promise<GitResult>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
/** Mode git records for a gitlink — a tree entry that pins a submodule's commit. */
|
|
3
|
+
const GITLINK_MODE = '160000';
|
|
4
|
+
/**
|
|
5
|
+
* The small set of git plumbing the submodule commands are built from, bound to one working
|
|
6
|
+
* directory (the product repository or the submodule's clone inside it).
|
|
7
|
+
*
|
|
8
|
+
* Plain `git` through `execa` rather than a git library: every operation here is one command whose
|
|
9
|
+
* exit code is the answer (`merge-base --is-ancestor`, `rev-parse --verify`), and `@nzyme/cli`
|
|
10
|
+
* already depends on `execa`.
|
|
11
|
+
*/
|
|
12
|
+
export class GitRepository {
|
|
13
|
+
dir;
|
|
14
|
+
constructor(dir) {
|
|
15
|
+
this.dir = dir;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The gitlink of a submodule path — the exact submodule commit the repository's `HEAD` pins.
|
|
19
|
+
*
|
|
20
|
+
* Read from the tree of `HEAD` rather than from the submodule's checkout: the commit is what the
|
|
21
|
+
* product's CI tested, while the checkout may have moved since. Throws when the path is not a
|
|
22
|
+
* submodule at `HEAD`, so a typo in `--path` cannot silently act on nothing.
|
|
23
|
+
*/
|
|
24
|
+
async readGitlink(submodulePath) {
|
|
25
|
+
const entry = await this.git(['ls-tree', 'HEAD', '--', submodulePath]);
|
|
26
|
+
const match = /^(\d+) \w+ ([0-9a-f]+)\t/.exec(entry);
|
|
27
|
+
if (!match?.[2] || match[1] !== GITLINK_MODE) {
|
|
28
|
+
throw new Error(`"${submodulePath}" is not a submodule at HEAD of ${this.dir} (no gitlink in its tree).`);
|
|
29
|
+
}
|
|
30
|
+
return match[2];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Throws unless this directory is the top of a checked-out repository. An uninitialised
|
|
34
|
+
* submodule is an empty directory, and git run inside it would silently act on the parent
|
|
35
|
+
* repository instead.
|
|
36
|
+
*/
|
|
37
|
+
async assertCheckedOut() {
|
|
38
|
+
const prefix = await this.tryGit(['rev-parse', '--show-prefix']);
|
|
39
|
+
if (!prefix.ok || prefix.stdout !== '') {
|
|
40
|
+
throw new Error(`${this.dir} is not a checked-out submodule. Run \`git submodule update --init\` first.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Makes the history deep enough for an ancestry check. A shallow clone (what CI checkouts make by
|
|
45
|
+
* default) cuts the parent links `merge-base --is-ancestor` walks, so a perfectly linear
|
|
46
|
+
* fast-forward would look like a divergence.
|
|
47
|
+
*/
|
|
48
|
+
async ensureFullHistory(remote) {
|
|
49
|
+
if ((await this.git(['rev-parse', '--is-shallow-repository'])) === 'true') {
|
|
50
|
+
await this.git(['fetch', '--quiet', '--unshallow', remote]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fetches a ref (branch, tag or full SHA) from the remote and returns the commit it resolves to,
|
|
55
|
+
* or `null` when the remote does not have it — so callers can fall back to a local lookup.
|
|
56
|
+
*/
|
|
57
|
+
async fetchCommit(remote, ref) {
|
|
58
|
+
const fetched = await this.tryGit(['fetch', '--quiet', '--no-tags', remote, ref]);
|
|
59
|
+
if (!fetched.ok) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return await this.git(['rev-parse', '--verify', 'FETCH_HEAD^{commit}']);
|
|
63
|
+
}
|
|
64
|
+
/** The commit a local revision resolves to (tags peeled), or `null` when it does not exist locally. */
|
|
65
|
+
async resolveLocalCommit(revision) {
|
|
66
|
+
const resolved = await this.tryGit(['rev-parse', '--verify', '--quiet', `${revision}^{commit}`]);
|
|
67
|
+
return resolved.ok ? resolved.stdout : null;
|
|
68
|
+
}
|
|
69
|
+
/** Commits reachable from `to` but not from `from`, newest first — `git log from..to`. */
|
|
70
|
+
async listCommits(from, to) {
|
|
71
|
+
const output = await this.git(['log', '--format=%H %s', `${from}..${to}`]);
|
|
72
|
+
const commits = [];
|
|
73
|
+
for (const line of output.split('\n')) {
|
|
74
|
+
const separator = line.indexOf(' ');
|
|
75
|
+
if (separator > 0) {
|
|
76
|
+
commits.push({ sha: line.slice(0, separator), subject: line.slice(separator + 1) });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return commits;
|
|
80
|
+
}
|
|
81
|
+
/** Number of commits reachable from `to` but not from `from`. */
|
|
82
|
+
async countCommits(from, to) {
|
|
83
|
+
return Number(await this.git(['rev-list', '--count', `${from}..${to}`]));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The `https://github.com/<owner>/<repo>` URL of a remote, or `null` when it is not on GitHub.
|
|
87
|
+
*
|
|
88
|
+
* Reads the configured URL (not `remote get-url`, which applies `insteadOf` rewrites and so can
|
|
89
|
+
* return a URL with a token in it) and rebuilds it from owner and repo only — the result goes
|
|
90
|
+
* into a PR body, so nothing else from the URL may leak into it.
|
|
91
|
+
*/
|
|
92
|
+
async getGitHubRepoUrl(remote) {
|
|
93
|
+
const configured = await this.tryGit(['config', '--get', `remote.${remote}.url`]);
|
|
94
|
+
const match = /github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/.exec(configured.stdout);
|
|
95
|
+
if (!configured.ok || !match) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
return `https://github.com/${match[1]}/${match[2]}`;
|
|
99
|
+
}
|
|
100
|
+
/** Runs git and returns its trimmed stdout; throws with git's stderr when it fails. */
|
|
101
|
+
async git(args) {
|
|
102
|
+
const result = await this.tryGit(args);
|
|
103
|
+
if (!result.ok) {
|
|
104
|
+
throw new Error(`git ${args.join(' ')} failed (exit ${result.exitCode}) in ${this.dir}:\n${result.stderr}`);
|
|
105
|
+
}
|
|
106
|
+
return result.stdout;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Runs git without throwing on a non-zero exit. Terminal prompts are disabled: in CI a missing
|
|
110
|
+
* credential must fail the step, not hang it until the job times out.
|
|
111
|
+
*/
|
|
112
|
+
async tryGit(args) {
|
|
113
|
+
const result = await execa('git', args, {
|
|
114
|
+
cwd: this.dir,
|
|
115
|
+
reject: false,
|
|
116
|
+
env: { GIT_TERMINAL_PROMPT: '0' },
|
|
117
|
+
});
|
|
118
|
+
// No exit code when git could not be started at all (e.g. a missing working directory).
|
|
119
|
+
const exitCode = result.exitCode ?? 1;
|
|
120
|
+
const stderr = result.stderr.trim();
|
|
121
|
+
return {
|
|
122
|
+
ok: exitCode === 0,
|
|
123
|
+
exitCode,
|
|
124
|
+
stdout: result.stdout.trim(),
|
|
125
|
+
stderr: stderr || (result instanceof Error ? result.message : ''),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=GitRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitRepository.js","sourceRoot":"","sources":["../../src/submodule/GitRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,oFAAoF;AACpF,MAAM,YAAY,GAAG,QAAQ,CAAC;AAgB9B;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACD,GAAG;IAAxB,YAAqB,GAAW;mBAAX,GAAG;IAAW,CAAC;IAEpC;;;;;;OAMG;IACH,KAAK,CAAC,WAAW,CAAC,aAAqB;QACnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrD,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,IAAI,aAAa,mCAAmC,IAAI,CAAC,GAAG,4BAA4B,CAAC,CAAC;QAC9G,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QAClB,MAA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
|
+
/** Inputs for {@link bumpSubmodule}. */
|
|
3
|
+
export interface BumpSubmoduleOptions {
|
|
4
|
+
/** The product repository (its working directory). */
|
|
5
|
+
repoDir: string;
|
|
6
|
+
/** Path of the submodule within the product repository, e.g. `nzyme`. */
|
|
7
|
+
submodulePath: string;
|
|
8
|
+
/**
|
|
9
|
+
* What to move the submodule to: a branch (`main`, or `origin/main` — the remote prefix is
|
|
10
|
+
* stripped and the branch fetched fresh), a tag or a commit SHA.
|
|
11
|
+
*/
|
|
12
|
+
source: string;
|
|
13
|
+
/** Remote of the submodule to fetch from. */
|
|
14
|
+
remote: string;
|
|
15
|
+
}
|
|
16
|
+
/** The gitlink already points at the source commit; nothing was changed or staged. */
|
|
17
|
+
export interface BumpUnchanged {
|
|
18
|
+
changed: false;
|
|
19
|
+
submodulePath: string;
|
|
20
|
+
source: string;
|
|
21
|
+
current: string;
|
|
22
|
+
}
|
|
23
|
+
/** The submodule was moved and the new gitlink staged. */
|
|
24
|
+
export interface BumpChanged {
|
|
25
|
+
changed: true;
|
|
26
|
+
submodulePath: string;
|
|
27
|
+
source: string;
|
|
28
|
+
previous: string;
|
|
29
|
+
current: string;
|
|
30
|
+
/** Commits the bump brings in, newest first (`git log previous..current`). */
|
|
31
|
+
commits: CommitSummary[];
|
|
32
|
+
/** Commits of the previous pin that the new one does not contain — non-zero means a rollback or divergence. */
|
|
33
|
+
droppedCount: number;
|
|
34
|
+
/** `https://github.com/<owner>/<repo>` of the submodule, or `null` when it is not on GitHub. */
|
|
35
|
+
repoUrl: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** Outcome of {@link bumpSubmodule}. */
|
|
38
|
+
export type BumpResult = BumpUnchanged | BumpChanged;
|
|
39
|
+
/**
|
|
40
|
+
* Moves the submodule to a source ref and stages the new gitlink in the product repository —
|
|
41
|
+
* the first half of a bump PR, whose CI then decides whether that nzyme commit is good for the
|
|
42
|
+
* product. Commits and pushes nothing: how the change lands (PR, auto-merge, cadence) is the
|
|
43
|
+
* product's policy, not the CLI's.
|
|
44
|
+
*/
|
|
45
|
+
export declare function bumpSubmodule(options: BumpSubmoduleOptions): Promise<BumpResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { GitRepository } from './GitRepository.js';
|
|
3
|
+
/**
|
|
4
|
+
* Moves the submodule to a source ref and stages the new gitlink in the product repository —
|
|
5
|
+
* the first half of a bump PR, whose CI then decides whether that nzyme commit is good for the
|
|
6
|
+
* product. Commits and pushes nothing: how the change lands (PR, auto-merge, cadence) is the
|
|
7
|
+
* product's policy, not the CLI's.
|
|
8
|
+
*/
|
|
9
|
+
export async function bumpSubmodule(options) {
|
|
10
|
+
const { repoDir, submodulePath, source, remote } = options;
|
|
11
|
+
const product = new GitRepository(repoDir);
|
|
12
|
+
const previous = await product.readGitlink(submodulePath);
|
|
13
|
+
const submodule = new GitRepository(path.resolve(repoDir, submodulePath));
|
|
14
|
+
await submodule.assertCheckedOut();
|
|
15
|
+
await submodule.ensureFullHistory(remote);
|
|
16
|
+
const current = await resolveSource({ submodule, remote, source });
|
|
17
|
+
if (current === previous) {
|
|
18
|
+
return { changed: false, submodulePath, source, current };
|
|
19
|
+
}
|
|
20
|
+
await submodule.git(['-c', 'advice.detachedHead=false', 'checkout', '--quiet', '--detach', current]);
|
|
21
|
+
await product.git(['add', '--', submodulePath]);
|
|
22
|
+
return {
|
|
23
|
+
changed: true,
|
|
24
|
+
submodulePath,
|
|
25
|
+
source,
|
|
26
|
+
previous,
|
|
27
|
+
current,
|
|
28
|
+
commits: await submodule.listCommits(previous, current),
|
|
29
|
+
droppedCount: await submodule.countCommits(current, previous),
|
|
30
|
+
repoUrl: await submodule.getGitHubRepoUrl(remote),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the source to a commit, fetching it first so a branch means its tip on the remote now,
|
|
35
|
+
* not whatever the clone last saw. Falls back to a local lookup for what cannot be fetched by name
|
|
36
|
+
* (an abbreviated SHA).
|
|
37
|
+
*/
|
|
38
|
+
async function resolveSource(options) {
|
|
39
|
+
const { submodule, remote, source } = options;
|
|
40
|
+
const remotePrefix = `${remote}/`;
|
|
41
|
+
const ref = source.startsWith(remotePrefix) ? source.slice(remotePrefix.length) : source;
|
|
42
|
+
const fetched = await submodule.fetchCommit(remote, ref);
|
|
43
|
+
if (fetched) {
|
|
44
|
+
return fetched;
|
|
45
|
+
}
|
|
46
|
+
const local = await submodule.resolveLocalCommit(source);
|
|
47
|
+
if (local) {
|
|
48
|
+
return local;
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Cannot resolve "${source}" to a commit in ${submodule.dir} (not on "${remote}", not local).`);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=bumpSubmodule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bumpSubmodule.js","sourceRoot":"","sources":["../../src/submodule/bumpSubmodule.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA2CnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC7D,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3D,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;IAE1D,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;IAC1E,MAAM,SAAS,CAAC,gBAAgB,EAAE,CAAC;IACnC,MAAM,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,EA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SAAS,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,KAAK,EAAE,CAAC;QACR,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,oBAAoB,SAAS,CAAC,GAAG,aAAa,MAAM,gBAAgB,CAAC,CAAC;AACnH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BumpChanged } from './bumpSubmodule.js';
|
|
2
|
+
/** How many commits a summary lists before pointing at the compare view for the rest. */
|
|
3
|
+
export declare const MAX_LISTED_COMMITS = 50;
|
|
4
|
+
/**
|
|
5
|
+
* Renders a bump as markdown for the bump PR's body: old → new, a compare link when the submodule
|
|
6
|
+
* is on GitHub, the commits it brings in and a warning when it drops commits of the previous pin.
|
|
7
|
+
*
|
|
8
|
+
* Reviewers of a bump PR are looking at the product repository, so issue references in commit
|
|
9
|
+
* subjects (`(#123)`, the squash-merge suffix) are qualified with the submodule's repository —
|
|
10
|
+
* unqualified they would link to the product's own PR #123.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderBumpSummary(bump: BumpChanged): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** How many commits a summary lists before pointing at the compare view for the rest. */
|
|
2
|
+
export const MAX_LISTED_COMMITS = 50;
|
|
3
|
+
/** Length of the abbreviated SHAs shown in a summary. */
|
|
4
|
+
const SHORT_SHA_LENGTH = 7;
|
|
5
|
+
/**
|
|
6
|
+
* Renders a bump as markdown for the bump PR's body: old → new, a compare link when the submodule
|
|
7
|
+
* is on GitHub, the commits it brings in and a warning when it drops commits of the previous pin.
|
|
8
|
+
*
|
|
9
|
+
* Reviewers of a bump PR are looking at the product repository, so issue references in commit
|
|
10
|
+
* subjects (`(#123)`, the squash-merge suffix) are qualified with the submodule's repository —
|
|
11
|
+
* unqualified they would link to the product's own PR #123.
|
|
12
|
+
*/
|
|
13
|
+
export function renderBumpSummary(bump) {
|
|
14
|
+
const { submodulePath, source, previous, current, commits, droppedCount, repoUrl } = bump;
|
|
15
|
+
const repoName = repoUrl?.replace('https://github.com/', '') ?? null;
|
|
16
|
+
const compareUrl = repoUrl ? `${repoUrl}/compare/${previous}...${current}` : null;
|
|
17
|
+
const lines = [
|
|
18
|
+
`## \`${submodulePath}\`: \`${shortSha(previous)}\` → \`${shortSha(current)}\``,
|
|
19
|
+
'',
|
|
20
|
+
`Source: \`${source}\`${compareUrl ? ` · [compare](${compareUrl})` : ''}`,
|
|
21
|
+
'',
|
|
22
|
+
];
|
|
23
|
+
if (droppedCount > 0) {
|
|
24
|
+
lines.push('> [!WARNING]', `> The new commit does not descend from the previous one: ${droppedCount} commit(s) of the previous`, '> pin are not in the new one. Merge only if dropping them is intended.', '');
|
|
25
|
+
}
|
|
26
|
+
lines.push(`${commits.length} new commit(s):`, '');
|
|
27
|
+
for (const commit of commits.slice(0, MAX_LISTED_COMMITS)) {
|
|
28
|
+
const sha = repoUrl
|
|
29
|
+
? `[\`${shortSha(commit.sha)}\`](${repoUrl}/commit/${commit.sha})`
|
|
30
|
+
: `\`${shortSha(commit.sha)}\``;
|
|
31
|
+
lines.push(`- ${sha} ${qualifyIssueReferences(commit.subject, repoName)}`);
|
|
32
|
+
}
|
|
33
|
+
const hidden = commits.length - MAX_LISTED_COMMITS;
|
|
34
|
+
if (hidden > 0) {
|
|
35
|
+
lines.push(`- … and ${hidden} more${compareUrl ? ` — see [the full comparison](${compareUrl})` : ''}`);
|
|
36
|
+
}
|
|
37
|
+
return lines.join('\n') + '\n';
|
|
38
|
+
}
|
|
39
|
+
/** The abbreviated form of a commit SHA. */
|
|
40
|
+
function shortSha(sha) {
|
|
41
|
+
return sha.slice(0, SHORT_SHA_LENGTH);
|
|
42
|
+
}
|
|
43
|
+
/** Rewrites bare `#123` references to `owner/repo#123`, so they link to the submodule's repository. */
|
|
44
|
+
function qualifyIssueReferences(subject, repoName) {
|
|
45
|
+
if (!repoName) {
|
|
46
|
+
return subject;
|
|
47
|
+
}
|
|
48
|
+
return subject.replace(/(^|[\s(])#(\d+)\b/g, `$1${repoName}#$2`);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=renderBumpSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderBumpSummary.js","sourceRoot":"","sources":["../../src/submodule/renderBumpSummary.ts"],"names":[],"mappings":"AAEA,yFAAyF;AACzF,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,yDAAyD;AACzD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IAC/C,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC1F,MAAM,QAAQ,GAAG,OAAO,EAAE,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC;IACrE,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,YAAY,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAElF,MAAM,KAAK,GAAG;QACV,QAAQ,aAAa,SAAS,QAAQ,CAAC,QAAQ,CAAC,UAAU,QAAQ,CAAC,OAAO,CAAC,IAAI;QAC/E,EAAE;QACF,aAAa,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,gBAAgB,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACzE,EAAE;KACL,CAAC;IAEF,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CACN,cAAc,EACd,4DAA4D,YAAY,4BAA4B,EACpG,wEAAwE,EACxE,EAAE,CACL,CAAC;IACN,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,iBAAiB,EAAE,EAAE,CAAC,CAA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