X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fbuild_tools%2Fautorevision.sh;h=d8a5c8b0ac50296de0518955262158ec4f8d2193;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=3de1b2be6192c7ae0052536d7bedeb6d94aebe75;hpb=4cf9074f6442c2a1c4979efbccdbd154f2ee39a2;p=synfig.git diff --git a/synfig-studio/trunk/build_tools/autorevision.sh b/synfig-studio/trunk/build_tools/autorevision.sh index 3de1b2b..d8a5c8b 100644 --- a/synfig-studio/trunk/build_tools/autorevision.sh +++ b/synfig-studio/trunk/build_tools/autorevision.sh @@ -1,6 +1,7 @@ #!/bin/sh # Copyright 2008 Paul Wise +# Copyright 2009 Konstantin Dmitriev # # This package is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -12,6 +13,22 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. +get_git_id(){ + export SCM=git + export REVISION_ID=`cd "$1"; git log --no-color -1 | head -n 1 | cut -f 2 -d ' '` + export BRANCH="`cd "$1"; git branch -a --no-color --contains HEAD | sed -e s/\*\ // | sed -e s/\(no\ branch\)// | tr '\n' ' ' | tr -s ' ' | sed s/^' '//`" + if ( echo $BRANCH | egrep origin/master > /dev/null ); then + #give a priority to master branch + BRANCH='master' + else + BRANCH=`echo $BRANCH | cut -d ' ' -f 1` + BRANCH=${BRANCH##*/} + fi + export REVISION=`git show --pretty=format:%ci HEAD | head -c 10 | tr -d '-'` + export COMPARE=`git rev-parse --git-dir` + # The extra * at the end is for Modified + #REVISION="$REVISION"`cd "$1"; [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"` +} get_git_svn_id(){ export SCM=git-svn @@ -41,7 +58,9 @@ fi # Extract the revision from SVN/git/etc -if [ -d "$1/.git/svn" ] ; then +if git rev-parse --git-dir > /dev/null 2>&1 ; then + get_git_id "." +elif [ -d "$1/.git/svn" ] ; then get_git_svn_id "$1" elif [ -d "$1/../.git/svn" ] ; then get_git_svn_id "$1/.." @@ -66,7 +85,6 @@ fi # Abort if the header is newer if [ "$COMPARE" -ot "$HEADER" ] ; then exit; fi - # Set the development version string if [ x = "x$DEVEL_VERSION" ] ; then if [ x != "x$REVISION" ] ; then @@ -74,6 +92,8 @@ if [ x = "x$DEVEL_VERSION" ] ; then DEVEL_VERSION="SVN r$REVISION" elif [ $SCM = git-svn ] ; then DEVEL_VERSION="SVN r$REVISION (via git)" + elif [ $SCM = git ] ; then + DEVEL_VERSION="Revision: ${REVISION}\\\\nBranch: ${BRANCH}\\\\nRevision ID: ${REVISION_ID}" elif [ $SCM = manual ] ; then DEVEL_VERSION="$REVISION (manually configured)" fi @@ -83,6 +103,6 @@ fi # Output the header if [ x != "x$DEVEL_VERSION" ] ; then - echo "#define SHOW_EXTRA_INFO" > "$HEADER" - echo "#define DEVEL_VERSION \"$DEVEL_VERSION\"" >> "$HEADER" + printf "#define SHOW_EXTRA_INFO\n" > "$HEADER" + printf "#define DEVEL_VERSION \"$DEVEL_VERSION\"\n" >> "$HEADER" fi