Message ID | d55f4b29e90d5cf78d2f3472f3cc774f9058445b.1499645991.git.mschiffer@universe-factory.net |
---|---|
State | Changes Requested |
Delegated to: | John Crispin |
Headers | show |
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@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 >
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
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@universe-factory.net> --- scripts/getver.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)