Skip to content

Commit 1f0c3e0

Browse files
committed
v8: allow incomplete SHA for backports
1 parent d5aa22d commit 1f0c3e0

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

lib/update-v8/backport.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ exports.commitBackport = function commitBackport() {
3030
return {
3131
title: 'Commit patch',
3232
task: async(ctx) => {
33-
const messageTitle = `deps: cherry-pick ${ctx.sha.substring(
33+
const messageTitle = `deps: cherry-pick ${ctx.fullSha.substring(
3434
0,
3535
7
3636
)} from upstream V8`;
3737
const indentedMessage = ctx.message.replace(/\n/g, '\n ');
3838
const messageBody =
3939
'Original commit message:\n\n' +
4040
` ${indentedMessage}\n\n` +
41-
`Refs: https://github.com/v8/v8/commit/${ctx.sha}`;
41+
`Refs: https://github.com/v8/v8/commit/${ctx.fullSha}`;
4242

4343
await ctx.execGitNode('add', 'deps/v8');
4444
await ctx.execGitNode('commit', '-m', messageTitle, '-m', messageBody);
@@ -51,15 +51,11 @@ function generatePatch() {
5151
title: 'Generate patch',
5252
task: async(ctx) => {
5353
const sha = ctx.sha;
54-
if (!sha || sha.length !== 40) {
55-
throw new Error(
56-
'--sha option is required and must be 40 characters long'
57-
);
58-
}
54+
const fullSha = ctx.fullSha = await ctx.execGitV8('rev-parse', sha);
5955
try {
6056
const [patch, message] = await Promise.all([
61-
ctx.execGitV8('format-patch', '--stdout', `${sha}^..${sha}`),
62-
ctx.execGitV8('log', '--format=%B', '-n', '1', sha)
57+
ctx.execGitV8('format-patch', '--stdout', `${fullSha}^..${fullSha}`),
58+
ctx.execGitV8('log', '--format=%B', '-n', '1', fullSha)
6359
]);
6460
ctx.patch = patch.stdout;
6561
ctx.message = message.stdout;

0 commit comments

Comments
 (0)