git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Randall S. Becker" <rsbecker@nexbridge.com>
To: "'Martin Vejnár'" <vejnar.martin@gmail.com>, git@vger.kernel.org
Subject: RE: Calculating major.minor.patch from commit hash
Date: Thu, 13 Feb 2020 09:46:22 -0500	[thread overview]
Message-ID: <014f01d5e27c$5f5166d0$1df43470$@nexbridge.com> (raw)
In-Reply-To: <CAJFfRmt65DV5bZa5yTvg9sDb8SS8dFFyX7Zm23T7mAHL58v1Lw@mail.gmail.com>

On February 13, 2020 9:41 AM, Martin Vejnár wrote:
> To: git@vger.kernel.org
> Subject: Calculating major.minor.patch from commit hash
> 
> I'd like my releases to have major.minor.patch version number. While
> increments of major.minor are something one has to do manually, I don't
> want to do that for patch.
> 
> So I was thinking of having a VERSION file in the repo containing major.minor
> and then calculate patch at the given commit C automatically as the length
> of the longest path starting at C in the subgraph containing only commits in
> which VERSION is the same as C's.
> 
> I can do that pretty easily right now by
> 
> * identifying commits in which VERSION changes with `git log -- VERSION`
> and then
> * walking the graph in topo order with `git log --format=format:"%H %P"`.
> 
> The latter step can terminate early, so it doesn't have to walk the entire
> repo, but the latter walks everything and can be quite slow.
> 
> Is there a more efficient way to do this?
> 
> If not, would there be an interest in a new builtin (git-depth?) that would
> calculate the value?

You should consider using annotated tags and the git describe command to derive your release number. We do this for all of our products and it works very well. For example:

$ git tag -a 1.6.4 commit-hash

Then, when building your release:

$ git describe --long --first-parent

Good luck,
Randall

-- Brief whoami:
 NonStop developer since approximately 211288444200000000
 UNIX developer since approximately 421664400
-- In my real life, I talk too much.




  reply	other threads:[~2020-02-13 14:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 14:40 Calculating major.minor.patch from commit hash Martin Vejnár
2020-02-13 14:46 ` Randall S. Becker [this message]
2020-02-13 14:54   ` Martin Vejnár
2020-02-14  0:27     ` brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='014f01d5e27c$5f5166d0$1df43470$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=git@vger.kernel.org \
    --cc=vejnar.martin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).