{"thread":{"id":"52796","subject":"Calculating major.minor.patch from commit hash","startedAt":"2020-02-13T14:41:09Z","lastAt":"2020-02-14T00:27:20Z","messageCount":4,"participants":["Martin Vejnár","Randall S. Becker","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"391663","messageId":"CAJFfRmt65DV5bZa5yTvg9sDb8SS8dFFyX7Zm23T7mAHL58v1Lw@mail.gmail.com","threadId":"52796","inReplyTo":null,"subject":"Calculating major.minor.patch from commit hash","fromName":"Martin Vejnár","fromEmail":"vejnar.martin@gmail.com","sentAt":"2020-02-13T14:40:55Z","receivedAt":"2020-02-13T14:41:09Z","isPatch":false,"sender":{"key":"vejnar.martin@gmail.com","avatar":null},"body":"I'd like my releases to have major.minor.patch version number. While\nincrements of major.minor are something one has to do manually, I\ndon't want to do that for patch.\n\nSo I was thinking of having a VERSION file in the repo containing\nmajor.minor and then calculate patch at the given commit C\nautomatically as the length of the longest path starting at C in the\nsubgraph containing only commits in which VERSION is the same as C's.\n\nI can do that pretty easily right now by\n\n* identifying commits in which VERSION changes with `git log --\nVERSION` and then\n* walking the graph in topo order with `git log --format=format:\"%H %P\"`.\n\nThe latter step can terminate early, so it doesn't have to walk the\nentire repo, but the latter walks everything and can be quite slow.\n\nIs there a more efficient way to do this?\n\nIf not, would there be an interest in a new builtin (git-depth?) that\nwould calculate the value?\n-- \nMartin\n"},{"id":"391665","messageId":"014f01d5e27c$5f5166d0$1df43470$@nexbridge.com","threadId":"52796","inReplyTo":"CAJFfRmt65DV5bZa5yTvg9sDb8SS8dFFyX7Zm23T7mAHL58v1Lw@mail.gmail.com","subject":"RE: Calculating major.minor.patch from commit hash","fromName":"Randall S. Becker","fromEmail":"rsbecker@nexbridge.com","sentAt":"2020-02-13T14:46:22Z","receivedAt":"2020-02-13T14:46:33Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On February 13, 2020 9:41 AM, Martin Vejnár wrote:\n> To: git@vger.kernel.org\n> Subject: Calculating major.minor.patch from commit hash\n> \n> I'd like my releases to have major.minor.patch version number. While\n> increments of major.minor are something one has to do manually, I don't\n> want to do that for patch.\n> \n> So I was thinking of having a VERSION file in the repo containing major.minor\n> and then calculate patch at the given commit C automatically as the length\n> of the longest path starting at C in the subgraph containing only commits in\n> which VERSION is the same as C's.\n> \n> I can do that pretty easily right now by\n> \n> * identifying commits in which VERSION changes with `git log -- VERSION`\n> and then\n> * walking the graph in topo order with `git log --format=format:\"%H %P\"`.\n> \n> The latter step can terminate early, so it doesn't have to walk the entire\n> repo, but the latter walks everything and can be quite slow.\n> \n> Is there a more efficient way to do this?\n> \n> If not, would there be an interest in a new builtin (git-depth?) that would\n> calculate the value?\n\nYou 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:\n\n$ git tag -a 1.6.4 commit-hash\n\nThen, when building your release:\n\n$ git describe --long --first-parent\n\nGood luck,\nRandall\n\n-- Brief whoami:\n NonStop developer since approximately 211288444200000000\n UNIX developer since approximately 421664400\n-- In my real life, I talk too much.\n\n\n\n"},{"id":"391666","messageId":"CAJFfRmt3w60Yq+HS9oVmGtfPMzLeKzFSnkwS7v4_xe+eEWSxzw@mail.gmail.com","threadId":"52796","inReplyTo":"014f01d5e27c$5f5166d0$1df43470$@nexbridge.com","subject":"Re: Calculating major.minor.patch from commit hash","fromName":"Martin Vejnár","fromEmail":"vejnar.martin@gmail.com","sentAt":"2020-02-13T14:54:48Z","receivedAt":"2020-02-13T14:55:01Z","isPatch":false,"sender":{"key":"vejnar.martin@gmail.com","avatar":null},"body":"On Thu, Feb 13, 2020 at 3:46 PM Randall S. Becker\n<rsbecker@nexbridge.com> wrote:\n> You should consider using annotated tags and the git describe command to derive your release number. [...]\n\nI'd like to avoid tags in this case, because a new tag/deletion of a\ntag could change the hash->version mapping and I'd like that to be\nstable.\n"},{"id":"391714","messageId":"20200214002713.GA6806@camp.crustytoothpaste.net","threadId":"52796","inReplyTo":"CAJFfRmt3w60Yq+HS9oVmGtfPMzLeKzFSnkwS7v4_xe+eEWSxzw@mail.gmail.com","subject":"Re: Calculating major.minor.patch from commit hash","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-02-14T00:27:13Z","receivedAt":"2020-02-14T00:27:20Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-02-13 at 14:54:48, Martin Vejnár wrote:\n> On Thu, Feb 13, 2020 at 3:46 PM Randall S. Becker\n> <rsbecker@nexbridge.com> wrote:\n> > You should consider using annotated tags and the git describe command to derive your release number. [...]\n> \n> I'd like to avoid tags in this case, because a new tag/deletion of a\n> tag could change the hash->version mapping and I'd like that to be\n> stable.\n\nTags, usually signed tags, are the traditional way to indicate versions,\nand with them, git describe is usually used to describe commits.  While\nit is possible to rewrite tags, people usually rely on convention and\nsocial sanction to not do that without good cause.\n\nIf that isn't enough for you, then you'll probably have to build things\nyourself.  I'm not sure Git provides functionality that finds the\nlongest path between two commits, but you can probably find the commit\ndepth like the following:\n\ngit log --format=\"%H\" -- VERSION | head -n1 | xargs -I{} git rev-list {}..HEAD | wc -l\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}