[LEDE-DEV] [PATCH 3/4] scripts/getver.sh: include branch name in revision string

Matthias Schiffer mschiffer at universe-factory.net
Mon Jul 10 03:04:43 PDT 2017


On 07/10/2017 02:19 AM, Matthias Schiffer wrote:
> To determine the originating branch of a commit, a file called "branch"
> must be added to the root of the repository (similar to the existing
> "version" file used to override the getver.sh logic). When no such file
> exists in the commit in question, the master branch is assumed.
> 
> Signed-off-by: Matthias Schiffer <mschiffer at universe-factory.net>

One downside of this approach I noticed is that all "old" commits from
lede-17.01 will still show the master branch even after a branch definition
file has been added. This could be solved by adding a commit ID
(1e1e3ef2fb5d482a56975b0b974046064e548b03) for 17.01 to getver.sh and treat
all descendant commits as lede-17.01.

I think we'd still want to have support for a branch definition file as
this patch adds and use that for future stable branches; it seems like a
nicer solution than explicitly adding all branches to getver.sh forever
(and is more flexible in regard to non-official branches).


> ---
>  scripts/getver.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/getver.sh b/scripts/getver.sh
> index 215bb036a5..f6d18bb3a3 100755
> --- a/scripts/getver.sh
> +++ b/scripts/getver.sh
> @@ -5,6 +5,10 @@ export LC_ALL=C
>  
>  GET_REV=$1
>  
> +get_branch() {
> +	git show "$1:branch" 2>/dev/null || echo 'master'
> +}
> +
>  try_version() {
>  	[ -f version ] || return 1
>  	REV="$(cat version)"
> @@ -42,7 +46,7 @@ try_git() {
>  			REV="${UPSTREAM_REV}+$((REV - UPSTREAM_REV))"
>  		fi
>  
> -		REV="${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
> +		REV="$(get_branch "$GET_REV")-${REV:+r$REV-$(git log -n 1 --format="%h" $UPSTREAM_BASE)}"
>  
>  		;;
>  	esac
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170710/80ff761f/attachment.sig>


More information about the Lede-dev mailing list