summaryrefslogtreecommitdiff
path: root/tools/get-scala-commit-date
blob: 6511ed98cadf7e5237fa0684a5562b21a0ddd2c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash
#
# Usage: get-scala-commit-date [dir]
# Figures out current commit date of a git clone.
# If no dir is given, current working dir is used.
#
# Example build version string:
#   20120312
#

[[ $# -eq 0 ]] || cd "$1"

if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
	lastcommitdate=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 1)
	lastcommithours=$(git log --format="%ci" HEAD | head -n 1 | cut -d ' ' -f 2)
else
	lastcommitdate=$(date +%Y-%m-%d)
	lastcommithours=$(date +%H:%M:%S)
fi

# 20120324
echo "${lastcommitdate//-/}-${lastcommithours//:/}"