]> AND Private Git Repository - loba.git/blob - setlocalversion
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Tracing API has changed. Disable it until its usage is fixed.
[loba.git] / setlocalversion
1 #!/bin/bash
2
3 # Inspired by linux-2.6/scripts/setlocalversion
4
5 set -e
6
7 FILE=localversion
8
9 compute_version()
10 {
11     if [ ! -d .git ]; then
12         return;
13     fi
14     head=$(git rev-parse --verify --short HEAD)
15     printf "~git-%s" "$head"
16     # Check for uncommitted changes
17     if git diff-index --name-only HEAD | read dummy; then
18         printf '%s' "-dirty"
19     fi
20
21 }
22
23 [ -f "$FILE" ] || touch "$FILE"
24
25 old_version=$(< "$FILE")
26 version=$(printf '"%s"\n' "$(compute_version)")
27
28 if [ "$version" != "$old_version" ]; then
29     echo "$version" > "$FILE"
30 fi