Skip to content

Commit

Permalink
restore GitVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
bwitham committed Feb 23, 2017
1 parent 3c9d595 commit 8481845
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif
define buildAsciidoc
mkdir -p tmp
git log --simplify-by-decoration --no-merges "--pretty=%h|$$|%ct|$$|%s|$$|%aN" `find $(filter-out tmp/asciidoc-config,$^) || true` | node ParseRevisions.js > $(patsubst %.asciidoc,%-docinfo.xml,$<)
@REVNUMBER=`$$HOOT_HOME/scripts/GitVersion.sh` ; \
@REVNUMBER=`$$HOOT_HOME/scripts/git/GitVersion.sh` ; \
REVDATE=`date -d @$$(git log -n 1 "--pretty=%at" ../.) "+%B %e, %Y"`; \
a2x -a docinfo --dblatex-opts "-P latex.output.revhistory=0 -P latex.unicode.use=1 -s styles/nga.sty --param doc.publisher.show=0" -a HasLatexMath -a "revdate=v$$REVNUMBER, $$REVDATE" $(A2X_QUIET) -f pdf $<
a2x -a docinfo --dblatex-opts "-P latex.output.revhistory=0 -P latex.unicode.use=1 -s styles/nga.sty --param doc.publisher.show=0" -a "revdate=v$$REVNUMBER, $$REVDATE" $(A2X_QUIET) -f text $<
Expand Down
48 changes: 48 additions & 0 deletions scripts/git/GitVersion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Provides a slightly more pleasant version number than the typical hash value.
#
# Optionally takes a list of files. If provided, then the latest commit of
# any of the files is used for calculating the version number.
#
# If there is no version information then UNKNOWN is returned.

set -e

DEF_VER=UNKNOWN-VERSION

LF='
'

# Is this a git repo? Do we have git?
if command -v git &> /dev/null; then
if git status &> /dev/null; then
HAS_GIT=true
fi
fi

REVISION=`git log -n 1 --pretty=%h $*`

# First see if there is a version file (included in release tarballs),
# then try git-describe, then default.
if test "$HAS_GIT" = "true" &&
VN=$(git describe --match "v[0-9]*" --abbrev=7 --tags $REVISION 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
v[0-9]*)
git update-index -q --refresh
test -z "$(git diff-index --name-only HEAD --)" ||
VN="$VN-dirty" ;;
esac
then
#VN=$(echo "$VN" | sed -e 's/-/./g');
PASS=1
else
VN="$DEF_VER"
fi

# VN is the full version number. E.g. 0.1.0 if it is a tag. 0.1.0-2-deadbeef
# if it is not a tagged version
VN=$(expr "$VN" : v*'\(.*\)')

echo $VN

0 comments on commit 8481845

Please sign in to comment.