Git tag not updated if custom commit message is specified
raulmt opened this issue · 4 comments
If you pass the -m
option to specify a custom message to npm version
the tag won't be updated. The reason is because the entire commit subject is passed to semver.valid
, but a custom message will contain more than just the version number. Do you think it would be ok to extract the version number from the subject rather than expecting the entire subject be the version number? or maybe with an optional parameter specifying a regexp to extract the version number from the subject? I think this is important since it's an official supported parameter in npm version
.
If you are ok with this I could submit a PR, but wanted to ask first in case you don't agree at all :)
Whoa, nice catch @raulmt
I think this would be a great addition, so go ahead. But first, I tested npm version patch -m ...
just now and it looks like the entire message get replaced. Where will you source the version number from?
P.S. This could help with better support for Yarn: #85 (comment)
Yes, it replaces the entire comment. But in the docs (https://docs.npmjs.com/cli/version.html) they explain (not highlighted enough in my opinion :) ) that you can use %s
in the text as placeholder for the version number:
If supplied with -m or --message config option, npm will use it as a commit message when creating a version commit. If the message config contains %s then that will be replaced with the resulting version number.
I will create a PR then :)
Yeah, but that means the user has to include it in the message in order for RNV to pick it up.
@stovmascript yes, if you don't include %s
, you won't have the version, unless you add ir manually. But since this is for people that want to customize this, and they can include the version either with %s or manually, I think it's good if this library can allow taking the version in a more permissive way. In the end I implemented it very permissively actually (#88) using semver.coerce
. So even a versioning commit like Bump to v2
would still allow RNV to pick and update that tag.
Thanks for the very quick replies! Please let me know what you think of #88.