From 5fa23309c53ce9f7ae5188375fa93f038df53c9c Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Thu, 18 May 2017 10:27:17 +0200 Subject: [PATCH] download_and_compile.sh: replace manually set version with the Git blob ID By setting the 'ident' attribute for /download_and_compile.sh, this replacement will be automatic whenever the file is checked out. Note: the ID is the 40-character hexadecimal blob object name in Git, it is *not* the commit ID. 'git show ' can be used to obtain the script contents from its blob object name (id). This will avoid spoiling every diff with the version number change, or alternatively having different versions of the same file displaying and logging the same version number. If download_and_compile.sh is moved to a different directory in FGMeta (or even renamed), then the path in .gitattributes must be adapted for the substitution to work (the '/' in .gitattributes anchors the match at the containing directory; I did this because download_and_compile.sh is a rather generic name, and there *might* be different scripts with the same name in other dirs...). --- .gitattributes | 1 + download_and_compile.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 5abe905..20c0b64 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,3 +20,4 @@ README.* text Makefile text ChangeLog text ChangeLog.* text +/download_and_compile.sh text ident diff --git a/download_and_compile.sh b/download_and_compile.sh index 5b71432..03919f6 100755 --- a/download_and_compile.sh +++ b/download_and_compile.sh @@ -17,7 +17,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -VERSION="2.34" +script_blob_id='$Id$' +# Slightly tricky substitution to avoid our regexp being wildly replaced with +# the blob name (id) when the script is checked out: +# +# First extract the hexadecimal blob object name followed by a '$' +VERSION="$(echo "$script_blob_id" | sed 's@\$Id: *\([0-9a-f]\+\) *@\1@')" +# Then remove the trailing '$' +VERSION="${VERSION%\$}" + FGVERSION="release/$(git ls-remote --heads https://git.code.sf.net/p/flightgear/flightgear|grep '\/release\/'|cut -f4 -d'/'|sort -t . -k 1,1n -k2,2n -k3,3n|tail -1)" #######################################################