Hacker News new | ask | show | jobs
by kazinator 1485 days ago
The downside is that you need a commit which serves no purpose other than to increment the number. The only content which is different is is the version number; you're effectively tagging the same software with an incremented version. Why tag the same thing with two different versions? You're only inviting merge conflicts with changes like this.

Unreleased software doesn't require a version number at all.

What you can do is incorporate some build identifier into local unreleased builds. It could be from the git sha, plus some indication of whether it was a dirty state or exactly that git sha.

The command does it:

  git describe --tags --dirty
It will produce a string consisting of the most recent tag, the number of commits since that tag, a portion of the hash and the word "dirty", all separated from each other by a dash. If there are no uncommited changes, then -dirty is omitted, and if there are no commits since the tag (we are at the tagged commit), then the count of commits and hash are omitted.

You can incorporate this sort of identifying string at build time; nothing is checked in. If you build the tagged release in a clean repo, the string will just be the tag. Only if you make new commits and/or have uncommited changes do you get a different string without having to commit anything.