[Dnsmasq-discuss] Snapshot archives downloaded from gitweb are not versioned properly
Simon Kelley
simon at thekelleys.org.uk
Tue Sep 13 11:48:21 UTC 2022
On 13/09/2022 09:10, Johnny S. Lee via Dnsmasq-discuss wrote:
> How about something like the following?
>
> diff --git a/VERSION b/VERSION
> index 998eb1f..29a22f8 100644
> --- a/VERSION
> +++ b/VERSION
> @@ -1 +1 @@
> -$Format:%d$
> +$Format:%d;%(describe)$
> diff --git a/bld/get-version b/bld/get-version
> index 1f51768..4ba3646 100755
> --- a/bld/get-version
> +++ b/bld/get-version
> @@ -24,13 +24,19 @@ if which git >/dev/null 2>&1 && \
> ([ -d .git ] || grep '^gitdir:' .git >/dev/null 2>&1) && \
> git describe >/dev/null 2>&1; then
> git describe | sed 's/^v//'
> -elif grep '\$Format:%d\$' $1/VERSION >/dev/null 2>&1; then
> +elif grep '\$Format:%d;%(describe)\$' $1/VERSION >/dev/null 2>&1; then
> # unsubstituted VERSION, but no git available.
> echo UNKNOWN
> else
> - vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep ^v[0-9]`
> + vers=`cut -d';' -f1 $1/VERSION | sed 's/[(), ]/,/ g' | tr ','
> '\n' | grep ^v[0-9]`
> + ret=$?
>
> - if [ $? -eq 0 ]; then
> + if [ ${ret} -ne 0 ]; then
> + vers=`cut -d';' -f2 $1/VERSION | grep ^v[0-9]`
> + ret=$?
> + fi
> +
> + if [ ${ret} -eq 0 ]; then
> echo "${vers}" | sort -k1.2,1.5Vr -k1.6,1.6 -k1.8,1.9Vr
> -k1.10,1.11Vr | head -n 1 | sed 's/^v//'
> else
> cat $1/VERSION
>
> This appends ";%(describe)" to the format.
> The script will try to parse the contents of %d first, then %(describe).
> This should have minimal impact.
>
Thanks for that. Reading up more, I think that just going to %(describe)
is the way to go. It seems to do exactly what's needed, and avoids all
the crazy sorting to get the latest commit from the output of %d.
get-version therefore gets simpler, which is better adding complexity.
Simon.
More information about the Dnsmasq-discuss
mailing list