Skip to content

Commit 84b5177

Browse files
authored
Add full commit range to omicron PR body (#1759)
add full commit range to omicron PR body
1 parent 26737fd commit 84b5177

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

tools/deno/bump-omicron.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ function getUploadAssetsWorkflowId() {
5959
])
6060
}
6161

62+
/**
63+
* These lines get printed in an Omicron PR, so any references to commits or
64+
* issues need to be qualified.
65+
*/
66+
function linkifyGitLog(line: string): string {
67+
const sha = line.slice(2, 10)
68+
const rest = line.slice(11).replace(/#\d+/g, (s) => 'oxidecomputer/console' + s)
69+
const shaLink = `[${sha}](https://github.com/oxidecomputer/console/commit/${sha})`
70+
71+
return `* ${shaLink} ${rest}`
72+
}
73+
6274
// script starts here
6375

6476
const args = flags.parse(Deno.args, {
@@ -108,9 +120,18 @@ if (oldCommit === newCommit) {
108120

109121
const commitRange = `${oldCommit.slice(0, 8)}...${newCommit.slice(0, 8)}`
110122

123+
const commits = run('git', ['log', '--graph', '--oneline', commitRange])
124+
// commits are console commits, so they won't auto-link in omicron
125+
const commitsMarkdown = commits.split('\n').map(linkifyGitLog).join('\n')
126+
127+
const changesLine = `https://github.com/oxidecomputer/console/compare/${commitRange}`
128+
111129
const branchName = 'bump-console-' + newCommit.slice(0, 8)
112130
const prTitle = 'Bump web console' + (args.message ? ` (${args.message})` : '')
113-
const prBody = `Changes: https://github.com/oxidecomputer/console/compare/${commitRange}`
131+
const prBody = `${changesLine}\n\n${commitsMarkdown}`
132+
133+
// markdown links make the inline preview unreadable, so leave them out
134+
const prBodyPreview = `${changesLine}\n\n${commits}`
114135

115136
console.log(`
116137
New contents of <omicron>/tools/console_version:
@@ -119,11 +140,12 @@ ${newVersionFile}
119140
120141
Branch: ${branchName}
121142
PR title: ${prTitle}
122-
PR body: ${prBody}
123-
124-
Console commits since current pinned version:
125143
126-
${run('git', ['log', '--graph', '--oneline', '--color=always', commitRange])}`)
144+
--------
145+
PR body
146+
--------
147+
148+
${prBodyPreview}`)
127149

128150
if (args.dryRun || !confirm('\nMake Omicron PR with these changes?')) {
129151
Deno.exit()

0 commit comments

Comments
 (0)