File: identify.sh

package info (click to toggle)
chicken 5.2.0-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 32,804 kB
  • sloc: ansic: 579,676; lisp: 71,716; tcl: 1,445; sh: 576; makefile: 58
file content (41 lines) | stat: -rwxr-xr-x 1,119 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
#!/bin/sh -e
#
# identify.sh - check for .git directory and obtain checked out revision and branch
#
# usage: identify.sh SOURCEDIR


# make sure file exists anyway, since branchname is a special case
if test \! -f "buildbranch"; then
    touch buildbranch
fi

rev0=`cat buildid || echo ""`
branchname0=`cat buildbranch || echo ""`
buildtime=`date +%Y-%m-%d`
host=`hostname`
usys=`uname`

if test -d "$1/.git"; then
    rev=`GIT_DIR="$1/.git" git rev-parse --short HEAD 2>/dev/null`
    branchname=`GIT_DIR="$1/.git" git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
elif test -d "$1/manual-html"; then
    # Assume this is a snapshot or release build; don't touch
    # identifying files to avoid a rebuild which needs chicken
    exit
else
    branchname=${branchname:-"custom"}
fi

case "${branchname}" in
    "") branchname="";;
    "(no branch)") branchname="";;
    "master") branchname="";;
    "release") branchname="";;
esac
if test "x${rev0}" \!= "x${rev}"; then
    echo ${rev} >buildid
fi
if test "x${branchname0}" \!= "x${branchname}"; then
    echo ${branchname} >buildbranch
fi