Skip to content

allow git-node land to work with full PR url (#213) #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/git/epilogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, but it might make more sense to merge this into the line above, and just say that $PRID can be the PR number or the PR URL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibfahn hm, i don't think it makes big difference, i think it's fine to have them on separate line? i'm okay with changing it though. just let me know...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't think it makes a big difference, which is why it was just a suggestion. If you think it's fine as is, then that's fine by me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, then ready to land i guess?


$ git rebase -i upstream/master # Put "edit" on every commit that's gonna stay

Expand Down
15 changes: 12 additions & 3 deletions components/git/land.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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 ' +
Expand Down
1 change: 1 addition & 0 deletions docs/git-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down