Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…sh for github-generated tarballs
  • Loading branch information...
commit 5ab7a813c12acfc711679e37c71ec33c1af341f0 1 parent 2bd0d5b
@toddlipcon toddlipcon authored
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
1  .archive-version
@@ -0,0 +1 @@
+$Format:%H$
View
1  .gitattributes
@@ -0,0 +1 @@
+.archive-version export-subst
View
28 src/get_build_revision.sh
@@ -1,7 +1,27 @@
-#!/bin/sh
+#!/bin/bash
@citrin
citrin added a note

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 Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-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 added a note

It seems that enough to use:

BIN=$(dirname $0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+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"
@citrin

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
@citrin

It seems that enough to use:

BIN=$(dirname $0)
@toddlipcon

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

Please sign in to comment.
Something went wrong with that request. Please try again.