-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.sh
executable file
·56 lines (47 loc) · 910 Bytes
/
hooks.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
APPDIR="."
function pre_clean {
rm -f $APPDIR/include/commit_ver.hrl
}
function pre_compile {
if [ ! -d $APPDIR/ebin ]; then
mkdir $APPDIR/ebin
fi
if [ ! -d $APPDIR/priv ]; then
mkdir $APPDIR/priv
fi
if [ ! -d $APPDIR/include ]; then
mkdir $APPDIR/include
fi
# record what commit/version the rep is at
COMMIT=""
if [ -d ".git" ]
then
COMMIT=`git log -1 --pretty=format:%H`
fi
if [ -e "$APPDIR/include/commit_ver.hrl" ] && [ ! $COMMIT ]
then
exit 0
else
if [ ! COMMIT ]
then
COMMIT="undefined"
else
COMMIT="\"$COMMIT\""
fi
fi
echo "%% automatically generated by precompile script. Editing means this
%% will just be overwritten.
-define(COMMIT, $COMMIT)." > $APPDIR/include/commit_ver.hrl
}
function post_compile {
cat success_message
}
case $1 in
"pre_compile")
pre_compile;;
"post_compile")
post_compile;;
"pre_clean")
pre_clean;;
esac