diff --git a/components/git/epilogue.js b/components/git/epilogue.js index e98fb312..19dbb0c7 100644 --- a/components/git/epilogue.js +++ b/components/git/epilogue.js @@ -11,6 +11,7 @@ $ ncu-config set branch master # Assuming you are landing commits on master $ git checkout master $ git node land --abort # Abort a landing session, just in case $ git node land $PRID # Start a new landing session +$ git node land $URL # Start a new landing session using the PR URL $ git rebase -i upstream/master # Put "edit" on every commit that's gonna stay diff --git a/components/git/land.js b/components/git/land.js index 90e01629..ba23de66 100644 --- a/components/git/land.js +++ b/components/git/land.js @@ -35,10 +35,11 @@ const landOptions = { function builder(yargs) { return yargs .options(landOptions).positional('prid', { - describe: 'ID of the Pull Request', - type: 'number' + describe: 'ID or URL of the Pull Request' }) .epilogue(epilogue) + .example('git node land https://github.com/nodejs/node/pull/12344', + 'Land https://github.com/nodejs/node/pull/12344 in the current directory') .example('git node land 12344', 'Land https://github.com/nodejs/node/pull/12344 in the current directory') .example('git node land --abort', @@ -58,8 +59,12 @@ const FINAL = 'final'; const CONTINUE = 'continue'; const ABORT = 'abort'; +const GITHUB_PULL_REQUEST_URL = /github.com\/[^/]+\/[^/]+\/pull\/(\d+)/; + function handler(argv) { - if (argv.prid && Number.isInteger(argv.prid)) { + if (argv.prid && + (Number.isInteger(argv.prid) || argv.prid.match(GITHUB_PULL_REQUEST_URL)) + ) { return land(START, argv); } const provided = []; @@ -124,6 +129,10 @@ async function main(state, argv, cli, req, dir) { } if (state === START) { + if (argv.prid.match && argv.prid.match(GITHUB_PULL_REQUEST_URL)) { + argv.prid = Number(argv.prid.split('/').pop()); + } + if (session.hasStarted()) { cli.warn( 'Previous `git node land` session for ' + diff --git a/docs/git-node.md b/docs/git-node.md index 60f4a4d5..509ca46a 100644 --- a/docs/git-node.md +++ b/docs/git-node.md @@ -32,6 +32,7 @@ $ ncu-config set branch master # Assuming you are landing commits on master $ git checkout master $ git node land --abort # Abort a landing session, just in case $ git node land $PRID # Start a new landing session +$ git node land $URL # Start a new landing session using the PR URL $ git rebase -i upstream/master # Put "edit" on every commit that's gonna stay