summaryrefslogtreecommitdiff
path: root/gen-id.sh
blob: 02be21a4a397e89cc64040b3a922219ed27c683c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
#
# Create a 10-character ID for this build.  If we're using a git tree,
# generate an ID of the form g[-*]XXXXXXXX (* = modified); otherwise use
# the passed-in timestamp.
#

if test -n "$GIT_DIR" -o -d ../.git -o -f ../.git; then
    ver="$(git rev-parse HEAD | cut -c1-8)"
    if test -n "$ver"; then
	if test -n "$(git diff-index --name-only HEAD)"; then
	    ver='g*'"$ver"
	else
	    ver='g-'"$ver"
	fi
    fi
fi
if test -z "$ver"; then
  echo "$1"
else
  echo "$ver"
fi