-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.sh
executable file
·55 lines (42 loc) · 1.09 KB
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Create a detailed version string for the program.
export TZ=UTC
RAW_TIME=`git log --date=local --pretty=format:%cd --date=raw -1 HEAD | awk -F" " '{print $1}'`
case `uname -s` in
Darwin)
DATE=`date -r "${RAW_TIME}" '+%Y.%m.%d-%TUTC'`
;;
*)
DATE=`date -u --date="@${RAW_TIME}" '+%Y.%m.%d-%TUTC'`
;;
esac
TAG=`git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null`
if [[ "$?" == "128" ]] ; then
TAG_DIFF="0000."
else
TAG_DIFF=`git log ${TAG}..HEAD --oneline | wc -l`
TAG_DIFF=`printf "%04d." ${TAG_DIFF}`
fi
GITVER=g`git log --pretty=format:%h -1 HEAD`
V=".${TAG_DIFF}${GITVER} ${DATE}"
t=$(dirname ${BASH_SOURCE[0]})
TAG=$(cat ${t}/fancydiff.cabal | grep ^version: | awk -F" " '{print $2}')
if [[ "$1" == "tag-with-simple" ]] ; then
echo ${TAG}-${TAG_DIFF}${GITVER}
exit
fi
if [[ "$1" == "tag" ]] ; then
echo ${TAG}
exit
fi
if [[ "$1" == "simple" ]] ; then
echo ${TAG_DIFF}${GITVER}
exit
fi
echo """
{-# LANGUAGE OverloadedStrings #-}
module Internal.Version where
import Data.Text
version :: Text
version = \"${V}\"
"""