Skip to content
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

Leave as-is crashes - exit code 1 #35

Open
perry-mitchell opened this issue Nov 15, 2019 · 3 comments
Open

Leave as-is crashes - exit code 1 #35

perry-mitchell opened this issue Nov 15, 2019 · 3 comments

Comments

@perry-mitchell
Copy link

When choosing an existing version (leave as-is in the menu) the app crashes as Git fails to commit without any changes:

$ bump prompt --commit --tag --push --preid r

?
The current version in package.json is 0.2.0
How would you like to bump it? leave as-is (0.2.0)
ℹ package.json did not need to be updated
ℹ package-lock.json did not need to be updated
git commit --message "release v0.2.0" exited with a status of 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] bump: `bump prompt --commit --tag --push --preid r`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] bump script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/x/.npm/_logs/2019-11-15T11_33_15_429Z-debug.log
ERROR: "bump" exited with 1.

In this case, version 0.2.0 has already been released and I simply wanted to leave the version as-is during deployment to another location.

Suggested fix: If a user selects leave-as-is, all other operations should be bypassed (git etc.) - Maybe process.exit(0)?

@perry-mitchell
Copy link
Author

Seems that this is still an issue:

image

I believe it's caused by the lack of checking which choice was made when selecting a version, as processing just continues here:

await gitCommit(operation);
await gitTag(operation);
// Run npm postversion script, if any
await runNpmScript(NpmScript.PostVersion, operation);
// Push the git commit and tag, if enabled
await gitPush(operation);

The versioning choice should be checked, and operations like git etc. should be skipped, in my opinion. Of course leave-as-is will always have such an issue with git as tags will always exist.. so the only option I believe is to skip these calls.

@JamesMessinger
Copy link
Member

The "leave as is" option was added because some people wanted Version Bump Prompt to do all the other stuff that it normally does (update other files, git commit, tag, push, etc.) even if the version number didn't change. That's why none of that stuff gets skipped when "leave as is" is selected.

I think the right workaround here is to add code to run "git status" first before running "git commit". If "git status" indicates that there are no changed files, then "git commit" would be skipped.

@perry-mitchell
Copy link
Author

Also good to check if the current commit is tagged, perhaps git describe --exact-match HEAD helps here. But perhaps this can be entirely avoided by checking the commit status, as you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants