From 213237dd3a6215bab7d301daf798f1d0b2153833 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Wed, 10 Jan 2024 20:00:34 -0700 Subject: [PATCH 1/2] proto: Consider lightweight Git tags when determining the version number By default, `git describe` only uses annotated tags. However, most projects use non-annotated or "lightweight" tags instead of annotated ones. Include the --tags flag in the example to consider all tag types. Signed-off-by: Alex Henrie --- proto/PKGBUILD-vcs.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/PKGBUILD-vcs.proto b/proto/PKGBUILD-vcs.proto index 49c6759f..c89bb50b 100644 --- a/proto/PKGBUILD-vcs.proto +++ b/proto/PKGBUILD-vcs.proto @@ -43,7 +43,7 @@ pkgver() { printf "r%s" "$(bzr revno)" # Git, tags available - printf "%s" "$(git describe --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" + printf "%s" "$(git describe --tags --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" # Git, no tags available printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" From 7c60bd841aecdf06e0837f52ba92ba0211b03a8b Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Wed, 10 Jan 2024 20:09:19 -0700 Subject: [PATCH 2/2] proto: Strip initial "v" from Git tag names Many projects use tags that are the version number prefixed with "v". In particular, GitHub suggests and encourages this naming convention. Include code in the example to remove the "v" so that the VCS package version number is comparable to the regular package version number. Signed-off-by: Alex Henrie --- proto/PKGBUILD-vcs.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/PKGBUILD-vcs.proto b/proto/PKGBUILD-vcs.proto index c89bb50b..0d802b73 100644 --- a/proto/PKGBUILD-vcs.proto +++ b/proto/PKGBUILD-vcs.proto @@ -43,7 +43,7 @@ pkgver() { printf "r%s" "$(bzr revno)" # Git, tags available - printf "%s" "$(git describe --tags --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g')" + printf "%s" "$(git describe --tags --long | sed 's/\([^-]*-\)g/r\1/;s/-/./g;s/^v//')" # Git, no tags available printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"