diff mbox series

version.sh: Include leading 'v' from git describe

Message ID 20190305205305.25370-1-sam@mendozajonas.com
State Accepted
Headers show
Series version.sh: Include leading 'v' from git describe | expand

Commit Message

samjonas March 5, 2019, 8:53 p.m. UTC
For some reason our version script removes the leading 'v' from the git
tag. This confuses some other tools such as Buildroot and is different
to most other projects, so include it again.

Additionally now that we have tagged releases just use git describe
rather than using a SHA and date to describe non-tag commits.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 version.sh | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

samjonas March 7, 2019, 1:51 a.m. UTC | #1
On Wed, 2019-03-06 at 09:53 +1300, Samuel Mendoza-Jonas wrote:
> For some reason our version script removes the leading 'v' from the git
> tag. This confuses some other tools such as Buildroot and is different
> to most other projects, so include it again.
> 
> Additionally now that we have tagged releases just use git describe
> rather than using a SHA and date to describe non-tag commits.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>

Merged as 3abf853

> ---
>  version.sh | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/version.sh b/version.sh
> index bf91f707..83cda7a0 100755
> --- a/version.sh
> +++ b/version.sh
> @@ -15,16 +15,8 @@ if head=$(git rev-parse --short=8 --verify HEAD 2>/dev/null); then
>  		suffix=-dirty
>  	fi
>  
> -	if tag=$(git describe --tags --exact-match 2>/dev/null); then
> -		# use a tag; remove any 'v' prefix from v<VERSION> tags
> -		tag=${tag#v}
> -		version=$(printf "%s%s" ${tag} ${suffix})
> -	else
> -		# Use the git commit revision for the package version, and add
> -		# a date prefix for easy comparisons.
> -		date=$(git log --pretty=format:"%ct" -1 HEAD)
> -		version=$(printf "%($datefmt)T.g%s%s" ${date} ${head} ${suffix})
> -	fi
> +	tag=$(git describe --tags 2>/dev/null)
> +	version=$(printf "%s%s" ${tag} ${suffix})
>  else
>  	# Check if a specific version is set, eg: by buildroot
>  	if [ ! -z "$PETITBOOT_VERSION" ];
diff mbox series

Patch

diff --git a/version.sh b/version.sh
index bf91f707..83cda7a0 100755
--- a/version.sh
+++ b/version.sh
@@ -15,16 +15,8 @@  if head=$(git rev-parse --short=8 --verify HEAD 2>/dev/null); then
 		suffix=-dirty
 	fi
 
-	if tag=$(git describe --tags --exact-match 2>/dev/null); then
-		# use a tag; remove any 'v' prefix from v<VERSION> tags
-		tag=${tag#v}
-		version=$(printf "%s%s" ${tag} ${suffix})
-	else
-		# Use the git commit revision for the package version, and add
-		# a date prefix for easy comparisons.
-		date=$(git log --pretty=format:"%ct" -1 HEAD)
-		version=$(printf "%($datefmt)T.g%s%s" ${date} ${head} ${suffix})
-	fi
+	tag=$(git describe --tags 2>/dev/null)
+	version=$(printf "%s%s" ${tag} ${suffix})
 else
 	# Check if a specific version is set, eg: by buildroot
 	if [ ! -z "$PETITBOOT_VERSION" ];