Chewi improved the format a fair bit when fixing bug 895908, but I have a suggestion to go a bit further. I'm a fan of gnulib's git-version-gen which is based on git-describe. In particular, https://git.savannah.gnu.org/cgit/gnulib.git/tree/build-aux/git-version-gen#n165. This would take us from e.g. portage-3.0.50_p3 to portage-3.0.50-3-xxxx where xxxx is the short form of the latest commit, and 3 is the number of commits since the last tag.
Seems reasonable.
I was curious about some of the history here, so for my own benefit: commit 1540d5eb4d8ab7f6a4813462acf9774f1e7ecc0e Author: Brian Dolbec <dolsen@gentoo.org> Date: Mon Dec 5 11:56:02 2016 -0800 portage/__init__.py: Fix live versioning to look for portage tags only commit 36a7f18dcbea9072cd6e2d7d923a9c7b4638aab9 Author: Mike Gilbert <floppym@gentoo.org> Date: Tue Jun 28 19:56:44 2016 -0400 portage.VERSION: compensate for new git tag format commit 7f089f0d6b25d539d1ff16abc6bcc930a613e22a Author: Zac Medico <zmedico@gentoo.org> Date: Mon Sep 20 00:36:12 2010 -0700 Use git rev-list --format option to simplify _LazyVersion committer timestamp code. commit 213dce575a3302ea3b24a81382a587533fd665e1 Author: Zac Medico <zmedico@gentoo.org> Date: Sun Sep 19 16:33:03 2010 -0700 Bug #338002 - Make _LazyVersion format portage.VERSION so that it is a valid version. commit 4f8e75b71f149b1aa0411051fe06a836f6f07cd3 Author: Zac Medico <zmedico@gentoo.org> Date: Sat Mar 27 14:35:11 2010 -0700 If portage.VERSION == HEAD then use a proxy to lazily call git describe --tags if it's accessed. commit f1b05b7098ba448a0987bc61224d6616dad3ecde Author: Zac Medico <zmedico@gentoo.org> Date: Wed Mar 24 00:03:51 2010 -0700 Don't use $Id or $Rev for version strings since that doesn't work with git. commit 722127498c5a14be27fb2dee5d4abd4589b855ce Author: Jason Stubbs <jstubbs@gentoo.org> Date: Sat Oct 15 06:09:42 2005 +0000 Adding svn revision property to portage.py's VERSION svn path=/main/branches/2.0/; revision=2133
Created attachment 887567 [details, diff] 0001-lib-use-more-pure-git-describe-output-for-version.patch
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=381fad5e3554ec94ec5626e8c17874f32b30b752 commit 381fad5e3554ec94ec5626e8c17874f32b30b752 Author: Sam James <sam@gentoo.org> AuthorDate: 2023-08-29 07:26:36 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-04-26 22:05:48 +0000 lib: use more pure git-describe output for --version Use `git describe --dirty` output rather than mangling git-describe and reinventing --dirty by manually checking for changes post-commit. We no longer mangle the 7th commit post-tag into _p7, but instead do: ${tag}-7-${last_commit}. This is similar to gnulib's git-version-gen (which we may still want to import, not sure, this seems enough for now) and is familiar output for developers. Example: * Old: 3.0.51_p7 * New: 3.0.51-7-g098b30548 Bug: https://bugs.gentoo.org/912209 Signed-off-by: Sam James <sam@gentoo.org> lib/portage/__init__.py | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-)