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 1 commit
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
Copy link
Member

Choose a reason for hiding this comment

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

Can you put something down in the comment indicating this is an alternative way to land a PR, not a necessary step? Something like

git node land $URL             # Or, 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
12 changes: 9 additions & 3 deletions components/git/land.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { runPromise } = require('../../lib/run');
const LandingSession = require('../../lib/landing_session');
const epilogue = require('./epilogue');
const yargs = require('yargs');
const isUrl = require('is-url');

const landOptions = {
apply: {
Expand Down Expand Up @@ -35,10 +36,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 @@ -59,7 +61,7 @@ const CONTINUE = 'continue';
const ABORT = 'abort';

function handler(argv) {
if (argv.prid && Number.isInteger(argv.prid)) {
if (argv.prid && (Number.isInteger(argv.prid) || isUrl(argv.prid))) {
Copy link
Member

@joyeecheung joyeecheung Mar 16, 2018

Choose a reason for hiding this comment

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

We don't really need this module, do we? We can simply use a regexp to validate & capture the id: argv.prid.match(/github.com\/[^\/]+\/[^\/]+\/pull\/(\d+)/)

Copy link
Member Author

Choose a reason for hiding this comment

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

@joyeecheung makes sense, also helps having less direct dependencies as they are 👍. making changes in few

return land(START, argv);
}
const provided = [];
Expand Down Expand Up @@ -124,6 +126,10 @@ async function main(state, argv, cli, req, dir) {
}

if (state === START) {
if (isUrl(argv.prid)) {
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
Copy link
Member

Choose a reason for hiding this comment

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

Can you update this line as well?

Copy link
Member Author

@aks- aks- Mar 22, 2018

Choose a reason for hiding this comment

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

@joyeecheung done, thanks for catching that


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

Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"core-validate-commit": "^3.5.0",
"figures": "^2.0.0",
"ghauth": "^3.2.1",
"is-url": "^1.2.2",
"jsdom": "^11.6.2",
"mkdirp": "^0.5.1",
"ora": "^1.3.0",
Expand Down