diff options
author | Mikael Larsson <mikael.xt.larsson@stericsson.com> | 2011-03-11 15:56:34 +0100 |
---|---|---|
committer | Henrik Aberg <henrik.aberg@stericsson.com> | 2011-05-18 09:39:44 +0200 |
commit | 4c9cca365a5086991afbd38b06c2be115836514f (patch) | |
tree | 828cdaf5eeb28d2663b3651d96d2d59a813f6280 /scripts | |
parent | 0ca27561b03415581c5d408cea2fbeb8e3b72c1f (diff) |
setlocalversion: Add support for version from specific tag
This patch makes it possible to specify a tag as input to setlocalversion.
If specified the version is then calculated from this tag and not the latest tag
as when not using this option.
ST-Ericsson ID: None
ST-Ericsson FOSS-OUT ID: Trivial
Change-Id: I168546efeb95978b53a5f7de992ddc955be26477
Signed-off-by: Mikael Larsson <mikael.xt.larsson@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/18195
Reviewed-by: Robert ROSENGREN <robert.rosengren@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/setlocalversion | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index ef8729f4858..f8296b8b591 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -10,23 +10,37 @@ # usage() { - echo "Usage: $0 [--save-scmversion] [srctree]" >&2 + echo "Usage: $0 [--save-scmversion] [-s srctree] [-t ref_tag]" >&2 exit 1 } scm_only=false srctree=. -if test "$1" = "--save-scmversion"; then - scm_only=true - shift -fi -if test $# -gt 0; then - srctree=$1 +match_option=--exact-match + +while [ $# -ne 0 ]; do + if test "$1" = "--save-scmversion"; then + scm_only=true + elif test "$1" = "-s"; then + shift + if test $# -ne 0 -a -d "$1"; then + srctree=$1 + else + usage + fi + elif test "$1" = "-t"; then + shift + if [ $# -ne 0 ]; then + match=" --tags --match "$1 + rev_refs="--refs refs/tags/"$1 + else + usage + fi + else + usage + fi shift -fi -if test $# -gt 0 -o ! -d "$srctree"; then - usage -fi +done scm_version() { @@ -47,8 +61,8 @@ scm_version() # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. - if [ -z "`git describe --exact-match 2>/dev/null`" ]; then - + if git name-rev --tags $rev_refs HEAD | \ + grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then # If only the short version is requested, don't bother # running further git commands if $short; then @@ -57,7 +71,7 @@ scm_version() fi # If we are past a tagged commit (like # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="`git describe 2>/dev/null`"; then + if atag="`git describe $match 2>/dev/null`"; then echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' # If we don't have a tag at all we print -g{commitish}. |