Skip to content

Commit c08bf62

Browse files
authored
feat(ncu-ci): accept URLs in ncu-ci run (#959)
1 parent a9d4268 commit c08bf62

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bin/ncu-ci.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ const args = yargs(hideBin(process.argv))
111111
builder: (yargs) => {
112112
yargs
113113
.positional('prid', {
114-
describe: 'ID of the PR',
115-
type: 'number'
114+
describe: 'ID of the PR or URL to the PR or its head commit',
115+
type: 'string'
116116
})
117117
.option('certify-safe', {
118118
describe: 'SHA of the commit that is expected to be at the tip of the PR head. ' +
@@ -574,6 +574,15 @@ async function main(command, argv) {
574574
// Prepare queue.
575575
switch (command) {
576576
case 'run': {
577+
const maybeURL = URL.parse(argv.prid);
578+
if (maybeURL?.host === 'github.com') {
579+
const [, owner, repo, , prid, , commit_sha] = maybeURL.pathname.split('/');
580+
argv.owner ||= owner;
581+
argv.repo ||= repo;
582+
argv.certifySafe ||= commit_sha;
583+
argv.prid = prid;
584+
}
585+
argv.prid = Number(argv.prid);
577586
const jobRunner = new RunPRJobCommand(cli, request, argv);
578587
return jobRunner.start();
579588
}

0 commit comments

Comments
 (0)