Permalink
Browse files

Add a template file .archive-version with git attributes to record ha…

…sh for github-generated tarballs
  • Loading branch information...
1 parent 2bd0d5b commit 5ab7a813c12acfc711679e37c71ec33c1af341f0 @toddlipcon toddlipcon committed Mar 17, 2011
Showing with 26 additions and 4 deletions.
  1. +1 −0 .archive-version
  2. +1 −0 .gitattributes
  3. +24 −4 src/get_build_revision.sh
View
@@ -0,0 +1 @@
+$Format:%H$
View
@@ -0,0 +1 @@
+.archive-version export-subst
View
@@ -1,7 +1,27 @@
-#!/bin/sh
+#!/bin/bash
@citrin

citrin Sep 14, 2011

After this change this script don't work on FreeBSD, and may be other systems where bash is installed not in /bin
If bash is really need better to use

#!/usr/bin/env bash
@toddlipcon

toddlipcon Sep 14, 2011

Member

Mind submitting a Pull Request for this fix? I wasn't aware any users ran on FreeBSD.

-if [ -z "$BUILD_REVISION" ]; then
- git rev-parse HEAD
-else
+# Allow user to specify - this is done by packages
+if [ -n "$BUILD_REVISION" ]; then
echo $BUILD_REVISION
+ exit
fi
+
+# If we're in git, use that
+BUILD_REVISION=$(git rev-parse HEAD 2>/dev/null)
+if [ -n "$BUILD_REVISION" ]; then
+ echo $BUILD_REVISION
+ exit
+fi
+
+# Otherwise try to use the .archive-version file which
+# is filled in by git exports (eg github downloads)
+BIN=$(dirname ${BASH_SOURCE:-0})
@citrin

citrin Sep 14, 2011

It seems that enough to use:

BIN=$(dirname $0)
+BUILD_REVISION=$(cat $BIN/../.archive-version 2>/dev/null)
+
+if [[ "$BUILD_REVISION" != *Format* ]]; then
+ echo "$BUILD_REVISION"
+ exit
+fi
+
+# Give up
+echo "Unknown build revision"

0 comments on commit 5ab7a81

Please sign in to comment.