forked from flackem/check_multi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_VERSION
executable file
·37 lines (33 loc) · 1.12 KB
/
mk_VERSION
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
#!/bin/sh
#
# pre-commit script to create version info into CM_VERSION
# $ ln -s mk_VERSION .git/hooks/pre-commit
#
# 1. call:
# - create version file CM_VERSION
# - create flag file
# - exit with RC1 (error) -> return to command line
#
# 2. call:
# - remove flag file
# - exit with RC0 (OK) -> commit
#
if [ ! -f CM_VERSION.version_is_updated ]; then
# the major version will be changed by 'make version'
MAJOR_VERSION=`awk -F\_ '{print $3}' CM_VERSION`
# the minor version is just to be increased by one
OLD_MINOR_VERSION=`awk -F\_ '{print $4}' CM_VERSION`
NEW_MINOR_VERSION=`expr $OLD_MINOR_VERSION + 1`
# output
DATESTRING=`date +%Y-%m-%d-%H:%M`
echo "check_multi_${MAJOR_VERSION}_${NEW_MINOR_VERSION}_${DATESTRING}" > CM_VERSION
echo "Created new version file CM_VERSION with check_multi_${MAJOR_VERSION}_${NEW_MINOR_VERSION}_${DATESTRING}"
echo "-> Now run commit again to check it in..."
touch CM_VERSION.version_is_updated
#--- exit with error first time (no commit is actually done)
exit 1
else
rm CM_VERSION.version_is_updated
#--- exit with OK the second time -> git commit is done now
exit 0
fi