diff mbox

[LEDE-DEV] scripts: getver.sh: include branch name in a revision string

Message ID 20170622085028.24540-1-zajec5@gmail.com
State Rejected
Delegated to: Rafał Miłecki
Headers show

Commit Message

Rafał Miłecki June 22, 2017, 8:50 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

The purpose of revision (r* number) is to provide a rough info about
build next to the (very) specific SHA-1. Unfortunately without a branch
name specified it's a bit misleading and what's more two commits may get
the same revision, e.g.:

For master branch:
./scripts/getver.sh bb9d2aa868
r3438-bb9d2aa868

For lede-17.01 branch:
./scripts/getver.sh 2e206c79cc
r3438-2e206c79cc

This can be solved by prepending a branch name so above example would
look like this:

./scripts/getver.sh 2e206c79cc
master-r2993+445-b9a408c2b4

Another option is to simply use "git describe" but it doesn't provide
info on amount of local commits so let's stick to own method for now.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 scripts/getver.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthias Schiffer June 22, 2017, 11:54 a.m. UTC | #1
On 06/22/2017 10:50 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> The purpose of revision (r* number) is to provide a rough info about
> build next to the (very) specific SHA-1. Unfortunately without a branch
> name specified it's a bit misleading and what's more two commits may get
> the same revision, e.g.:
> 
> For master branch:
> ./scripts/getver.sh bb9d2aa868
> r3438-bb9d2aa868
> 
> For lede-17.01 branch:
> ./scripts/getver.sh 2e206c79cc
> r3438-2e206c79cc
> 
> This can be solved by prepending a branch name so above example would
> look like this:
> 
> ./scripts/getver.sh 2e206c79cc
> master-r2993+445-b9a408c2b4
> 
> Another option is to simply use "git describe" but it doesn't provide
> info on amount of local commits so let's stick to own method for now.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

I don't think using the branch name is a good idea, as it may be a local
branch that still doesn't necessarily carry any information about the
remote branch it is based on.

Trying to base the branch name on the base branch (as it is already done
for the revision number and commit ID getver.sh returns) might be better,
but I'd prefer simply adding a branch name to a file that is read by
getver.sh as soon as a stable branch is created. It will need a bit of
additional work if the revision for a specific commit ID is requested
instead of the current state, but it should be doable.

Matthias


> ---
>  scripts/getver.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/getver.sh b/scripts/getver.sh
> index 9175f411db..479cf25b7d 100755
> --- a/scripts/getver.sh
> +++ b/scripts/getver.sh
> @@ -40,7 +40,7 @@ try_git() {
>  			REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
>  		fi
>  
> -		REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
> +		REV="${BRANCH}-${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
>  
>  		;;
>  	esac
>
diff mbox

Patch

diff --git a/scripts/getver.sh b/scripts/getver.sh
index 9175f411db..479cf25b7d 100755
--- a/scripts/getver.sh
+++ b/scripts/getver.sh
@@ -40,7 +40,7 @@  try_git() {
 			REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
 		fi
 
-		REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
+		REV="${BRANCH}-${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
 
 		;;
 	esac