markchalloner / git-semver

Git plugin for Semantic Versioning
MIT License
382 stars 43 forks source link

Add quiet option #40

Open fernandocollova opened 5 years ago

fernandocollova commented 5 years ago

Hi again,

As I was trying to add this script to another step in my release process, I stumbled upon the fact that it wasn't so easy to get only the version that was just tagged, as the script's output is always printed on each run.

So, instead of capturing the output and extracting only the last line, I added a -q, --quiet option. It's implemented with minimal changes to the code, borrowing heavily from tldp.org and has some design choices that are worth mentioning:

I'm specially hesitant about the second point, because although I want to keep the original behavior, I can totally see the situation in which you run something along the lines of git semver major --release "$(my_awesome_release_generator)" and after the awesome release generator returns nothing, the scripts outputs "something" instead of failing echoing nothing, which might incorrectly signal the code was actually tagged.

Also, a not about the implementation: I wasn't able to find a lot of documentation, but as far as I can tell from this, this, and this links, using /dev/null should be compatible with Cygwin and MinGW. And also again, I remember MacOS had a /dev/null so I guess it should also work with it.

So, if you find this feature useful, let me know of any problems of improvements, and thanks in advance for reviewing.

fernandocollova commented 5 years ago

Seeing the diff, I just realized I branched from the wrong commit, as I thought I made this MR when I didn't :/

I amended the lines differing from master, so this code is what I actually want to submit, but if you see it necessary, I'll close this MR and open a new one branching from the correct place.

Thanks, Fernando