aboutsummaryrefslogtreecommitdiff
path: root/contrib/git/rev_id.sh
blob: 0d3d8d5da85d1b780f701ecbbba0ba12921ec8b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#/bin/bash
command=$(git describe --match init --abbrev=12)
IFS="-"
cmdarray=($command)

if [ "$1" != "-id" ] && [ "$1" != "-hash" ]; then
  echo "Usage: $0 <-id | -hash>"
  exit
fi

if [ "${cmdarray[1]}" == "" ] || [ "${cmdarray[2]}" == "" ]; then
  echo "Error: No valid revision information found"
  exit 1
fi

if [ "$1" == "-id" ]; then
  echo ${cmdarray[1]}
elif [ "$1" == "-hash" ]; then
  echo ${cmdarray[2]:1}
fi