From 17ac094dd7d4cdb7e282ebcbe9213f6054500dc9 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 24 Jul 2025 11:01:44 +0200 Subject: [PATCH] feat(ncu-ci): accept URLs in `ncu-ci run` --- bin/ncu-ci.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/ncu-ci.js b/bin/ncu-ci.js index d4199a60..d1a8cfa4 100755 --- a/bin/ncu-ci.js +++ b/bin/ncu-ci.js @@ -111,8 +111,8 @@ const args = yargs(hideBin(process.argv)) builder: (yargs) => { yargs .positional('prid', { - describe: 'ID of the PR', - type: 'number' + describe: 'ID of the PR or URL to the PR or its head commit', + type: 'string' }) .option('certify-safe', { 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) { // Prepare queue. switch (command) { case 'run': { + const maybeURL = URL.parse(argv.prid); + if (maybeURL?.host === 'github.com') { + const [, owner, repo, , prid, , commit_sha] = maybeURL.pathname.split('/'); + argv.owner ||= owner; + argv.repo ||= repo; + argv.certifySafe ||= commit_sha; + argv.prid = prid; + } + argv.prid = Number(argv.prid); const jobRunner = new RunPRJobCommand(cli, request, argv); return jobRunner.start(); }