File: git-version-gen.sh

package info (click to toggle)
gerbv 2.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,332 kB
  • sloc: ansic: 25,151; sh: 3,585; lisp: 896; makefile: 436; cpp: 248; xml: 49; perl: 42
file content (44 lines) | stat: -rwxr-xr-x 788 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
#
# Generates gerbv version string from a given prefix and the current commit
# short id
#
# @warning Version will only be updated when reconfiguring! Will have no effect
#     on incremental builds
#
# @param $1 Version prefix

set -e


# Validate arguments
PREFIX="${1}"

if [ "" == "${PREFIX}" ]; then
	(>&2 echo "Usage: git-version-gen.sh <prefix>")
	exit 1
fi


# Validate environment
GIT=`command -v git`

if [ ! -x "${GIT}" ]; then
	(>&2 echo "\`git' missing")
	echo -n "${PREFIX}"
	exit 0
fi

if ! ${GIT} rev-parse --is-inside-work-tree >& /dev/null ; then
	echo -n "${PREFIX}"
	exit 0
fi

# Get commit short id
RELEASE_COMMIT=`"${GIT}" rev-parse HEAD`
RELEASE_COMMIT_SHORT="${RELEASE_COMMIT:0:6}"


# Output final version
echo -n "${PREFIX}~${RELEASE_COMMIT_SHORT}"