node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

Exception on PR creation where upstream repo can't be fast forwarded #399

Closed rotty3000 closed 9 years ago

rotty3000 commented 9 years ago

If I send another PR to a branch which I get rejected on the fastforward I get an error.

e.g.

[rotty@rotty-XPS-15-9530 (LPS-56630 $) portal-master]$ gh pr -s bchan
Submitting pull request to @brianchandotcom
To git@github.com:rotty3000/liferay-portal.git
 ! [rejected]        LPS-56630 -> LPS-56630 (non-fast-forward)
error: failed to push some refs to 'git@github.com:rotty3000/liferay-portal.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
/usr/lib/node_modules/gh/lib/exec.js:49
        throw err;
              ^
Error: Child process terminated with error code 1
    at Object.exports.spawnSyncStream (/usr/lib/node_modules/gh/lib/exec.js:45:15)
    at Object.exports.push (/usr/lib/node_modules/gh/lib/git.js:64:17)
    at /usr/lib/node_modules/gh/lib/cmds/pull-request.js:726:17
    at /usr/lib/node_modules/gh/node_modules/async/lib/async.js:735:13
    at iterate (/usr/lib/node_modules/gh/node_modules/async/lib/async.js:253:13)
    at Object.async.forEachOfSeries.async.eachOfSeries (/usr/lib/node_modules/gh/node_modules/async/lib/async.js:272:9)
    at Object.async.series (/usr/lib/node_modules/gh/node_modules/async/lib/async.js:734:15)
    at PullRequest.submit (/usr/lib/node_modules/gh/lib/cmds/pull-request.js:756:11)
    at /usr/lib/node_modules/gh/lib/cmds/pull-request.js:986:18
    at /usr/lib/node_modules/gh/lib/hooks.js:116:25

If gh handled this error cleanly then it'd be easier to see the issue. In fact git already prints out the problem pretty nicely.

henvic commented 9 years ago

git does print the error message clearly, but the exit code is a generic one (non-zero). This is why the stack trace is printed.

For avoiding to print the stack trace for errors like that (rejected updates) we have to spy on git's stderr / stdout to identify patterns (e.g., the phrase "Updates were rejected") to avoid printing the stack trace on these rarer situations. I am working on a solution.

henvic commented 9 years ago

This is a duplicate of https://github.com/node-gh/gh/issues/400

Closing.