Skip to content

Commit 598a3a2

Browse files
aks-joyeecheung
authored andcommitted
allow git-node land to work with full PR url (#213) (#219)
* allow git-node land to work with full PR url (#213) * replace is-url module with regex validation * land $URL: change help text
1 parent 704547d commit 598a3a2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

components/git/epilogue.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $ ncu-config set branch master # Assuming you are landing commits on master
1111
$ git checkout master
1212
$ git node land --abort # Abort a landing session, just in case
1313
$ git node land $PRID # Start a new landing session
14+
$ git node land $URL # Start a new landing session using the PR URL
1415
1516
$ git rebase -i upstream/master # Put "edit" on every commit that's gonna stay
1617

components/git/land.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ const landOptions = {
3535
function builder(yargs) {
3636
return yargs
3737
.options(landOptions).positional('prid', {
38-
describe: 'ID of the Pull Request',
39-
type: 'number'
38+
describe: 'ID or URL of the Pull Request'
4039
})
4140
.epilogue(epilogue)
41+
.example('git node land https://github.com/nodejs/node/pull/12344',
42+
'Land https://github.com/nodejs/node/pull/12344 in the current directory')
4243
.example('git node land 12344',
4344
'Land https://github.com/nodejs/node/pull/12344 in the current directory')
4445
.example('git node land --abort',
@@ -58,8 +59,12 @@ const FINAL = 'final';
5859
const CONTINUE = 'continue';
5960
const ABORT = 'abort';
6061

62+
const GITHUB_PULL_REQUEST_URL = /github.com\/[^/]+\/[^/]+\/pull\/(\d+)/;
63+
6164
function handler(argv) {
62-
if (argv.prid && Number.isInteger(argv.prid)) {
65+
if (argv.prid &&
66+
(Number.isInteger(argv.prid) || argv.prid.match(GITHUB_PULL_REQUEST_URL))
67+
) {
6368
return land(START, argv);
6469
}
6570
const provided = [];
@@ -124,6 +129,10 @@ async function main(state, argv, cli, req, dir) {
124129
}
125130

126131
if (state === START) {
132+
if (argv.prid.match && argv.prid.match(GITHUB_PULL_REQUEST_URL)) {
133+
argv.prid = Number(argv.prid.split('/').pop());
134+
}
135+
127136
if (session.hasStarted()) {
128137
cli.warn(
129138
'Previous `git node land` session for ' +

docs/git-node.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ $ ncu-config set branch master # Assuming you are landing commits on master
3232
$ git checkout master
3333
$ git node land --abort # Abort a landing session, just in case
3434
$ git node land $PRID # Start a new landing session
35+
$ git node land $URL # Start a new landing session using the PR URL
3536
3637
$ git rebase -i upstream/master # Put "edit" on every commit that's gonna stay
3738

0 commit comments

Comments
 (0)