servalproject / serval-dna

The Serval Project's core daemon that implements Distributed Numbering Architecture (DNA), MDP, VoMP, Rhizome, MeshMS, etc.
http://servalproject.org
Other
171 stars 80 forks source link

version_string.sh can not cope with non English git error messages. #88

Closed b0661 closed 9 years ago

b0661 commented 9 years ago

version_string.sh expects English git error messages. This is not always the case.

The following patch forces git to English messages.

It also checks for VERSION.txt as a last resort just before emitting an error. This helped me when developing in a virtual environment where only the serval-dna submodule was visible to the environment (no access to the top level .git).

From f8ec0f43999e4bcb1410fab8723e5645c001fd50 Mon Sep 17 00:00:00 2001
From: Bernhard Noelte <b0661n0e17e@gmail.com>
Date: Thu, 11 Dec 2014 17:49:36 +0100
Subject: [PATCH 1/1] Force git to emit english error messages and use
 VERSION.txt as a last resort if all git version detection failed.

---
 version_string.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/version_string.sh b/version_string.sh
index dd7c043..7792ca0 100755
--- a/version_string.sh
+++ b/version_string.sh
@@ -59,6 +59,9 @@ ME="${0##*/}"

 set -e

+# We search for english error messages
+alias git='LANG=en_GB git'
+
 refspec=
 allow_modified=true
 untracked_files=normal
@@ -162,6 +165,12 @@ case "$error" in
    ;;
 esac

+# All efforts failed. Use VERSION.txt if available.
+if [ -s VERSION.txt ] && [ $(cat VERSION.txt | wc -l) -eq 1 ]; then
+      cat VERSION.txt
+      exit 0
+fi
+
 echo "$ME: cannot form version string for repository: $(pwd -P)" >&2
 echo "$ME: git returned: ${error#fatal: }" >&2
 exit 2
-- 
1.9.1
lakeman commented 9 years ago

Good point. Depending on english text is silly. Fixed by 10a2edd.