-
Notifications
You must be signed in to change notification settings - Fork 132
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
Feature request #53
Comments
Thanks for your suggestion! Interest--and especially feedback on usage--is appreciated. While I understand the request, it is a little terse. Do you have specific use cases in mind? I have a few reservations about adding this new functionality:
|
Use case: auto-increment patch version on merge to master or release/ branches # get current branch
BRANCH=$(git rev-parse --abbrev-ref HEAD)
# get all tags visible from current branch, sort them and pick the last (highest)
LATEST_TAG=$(git tags --merged ${BRANCH} | semver sort | tail -1)
# bump the highest visible version
NEW_TAG=$(semver bump patch ${LATEST_TAG})
# add tag
git tag -a "${NEW_TAG}" -m "<meaningful comment>"
# push tag
git push --tags origin Here the |
Thanks for the use case. I agree that this is a typical situation in a CI pipeline. And you have run into the problem that "bumping" a given version is easier than determining the given version. (see, for example, storing the semver value) You note--and I tend to agree--that "highest" is really what you want. This code "almost" does it:
It seems to me that semver has the needed functionality (via compare) that one needs to write wrappers/code to get the job done. So, one question is whether or not it makes sense to incorporate some sort of "highest" function, adding to the API? Currently, no commands read from stdin. So, returning the "highest" from stdin would be a funny direction to take. The above code returns the highest from the given arguments. I mentioned that the code "almost" works. It fails when a tag like "0.0.0-rc1" exists. It fails when other tags (not semantic versions) exist. Your example code fails when there are no tags. I think the underlying problem is basing the "find-current-version-scheme" on git tags (and git itself). This is not really a semver-tool issue. However, adding features to semver-tool to support a git scheme (or, in general, use of a list of versions to determine the current version) is less than convincing. And since a few lines of code to make the scheme work and enable this particular use case is quite reasonable, it seems best to keep semver-tool simple. On the other hand, maybe "compare" is broken? Do people really use the returned value (-1,0,1) for logic other than selecting the newer value? It would be unfortunate if everyone was writing bash if-then-else's just to get the newest version when a function like |
|
I'm not seeing a lot of feedback on this issue. I'll mark it "won't fix" and see if this sparks something. Otherwise, after a while, it needs to go to the graveyard ... |
hi |
It would be helpful if you could explain your specific use-case (see, for example, the use-case described above and the subsequent conversation). Also, the above discussion mentions issues with tag sorting and @fsaintjacques offered the git gist for the common case of semantic version string sorting. Do these tag sorting schemes not work for you? It would be interesting to know exactly why not if the feature is to be pursued. |
Add a "sort" command, sorting version numbers read from STDIN.
The text was updated successfully, but these errors were encountered: