[beast] BUILD: buildtool.sh: throw a warning for shallow git repositories



commit 1c266193f9c24177188a0497d734b99e05a3e6cc
Author: Tim Janik <timj gnu org>
Date:   Thu Apr 7 19:43:32 2016 +0200

    BUILD: buildtool.sh: throw a warning for shallow git repositories
    
    Signed-off-by: Tim Janik <timj gnu org>

 buildtool.sh |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/buildtool.sh b/buildtool.sh
index f403f70..4f48027 100755
--- a/buildtool.sh
+++ b/buildtool.sh
@@ -15,8 +15,6 @@ mkconfig() # print shell variables describing package, version, commit id, monot
   SCRIPTPATH=`readlink -f $0`
   SCRIPTDIR=`dirname "$SCRIPTPATH"`
   pushd "$SCRIPTDIR" >/dev/null                        # cd PACKAGE/
-  gitdir=`git rev-parse --git-dir`
-  test ! -s "$gitdir/shallow" || die 7 "missing history, run: git fetch --unshallow"
   # extract configure.ac:AC_INIT package and version
   test -r configure.ac || die 7 "missing configure.ac"
   test -z "$PACKAGE" &&
@@ -33,7 +31,13 @@ mkconfig() # print shell variables describing package, version, commit id, monot
     CHANGELOGMSG="Release snapshot, git commit $COMMITID"
   fi
   # upstream version details
-  TOTAL_COMMITS=`git rev-list --count HEAD` # count commits to provide a monotonically increasing revision
+  gitdir=`git rev-parse --git-dir`
+  if test -s "$gitdir/shallow" ; then
+    echo "$SCRIPTNAME: warning shallow repository, run: git fetch --unshallow" >&2
+    TOTAL_COMMITS='0'
+  else
+    TOTAL_COMMITS=`git rev-list --count HEAD` # count commits to provide a monotonically increasing revision
+  fi
   if $DEVELOPMENT ; then
     UPSDETAIL="~git$TOTAL_COMMITS" # sort *before* UPSDETAIL="" (pre-release candidates)
   else
@@ -50,13 +54,15 @@ mkconfig() # print shell variables describing package, version, commit id, monot
   cat <<-__EOF
        PACKAGE=$PACKAGE
        UPSVERSION=$UPSVERSION
-       UPSDETAIL=$UPSDETAIL
        BUILDREV=$BUILDREV
-       UPLOADVERSION=$UPLOADVERSION
        DEVELOPMENT=$DEVELOPMENT
-       TOTAL_COMMITS=$TOTAL_COMMITS
        COMMITID=$COMMITID
        CHANGELOGMSG="$CHANGELOGMSG"
+       __EOF
+  test $TOTAL_COMMITS = 0 || cat <<-__EOF
+       TOTAL_COMMITS=$TOTAL_COMMITS
+       UPSDETAIL=$UPSDETAIL
+       UPLOADVERSION=$UPLOADVERSION
        DEBVERSION=$DEBVERSION
        __EOF
   popd >/dev/null                                      # cd OLDPWD


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]