aboutsummaryrefslogtreecommitdiff
path: root/tools/buildbot/gitrev-posix
blob: 9cec3d7d2b771c47cf2c349342ebdb3d71680ea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
#Print the git revision in the form yyyymmdd-abc1234
#Note: yyyymmdd is the date that abc1234 was committed and not today's date.

which git &>/dev/null
if [ "$?" != "0" ]; then
  echo "Unknown"
  exit 1
fi
git --no-pager log --abbrev=7 -1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}' 2>/dev/null
if [ "$?" != "0" ]; then
  echo "Unknown"
  exit 1
fi