forked from cilt-uct/oc-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit.sh
executable file
·55 lines (41 loc) · 911 Bytes
/
commit.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
#! /bin/bash
source config-dist.sh
CURRENT_USER=$(logname)
# Get the display name of the user
# params:
# $1 -- the section (if any)
# $2 -- the key
getCurrentUser() {
section="git"
key=$CURRENT_USER
value=$(
if [ -n "$section" ]; then
sed -n "/^\[$section\]/, /^\[/p" $DEPLOY_CFG_FOLDER/users.cfg
else
cat $DEPLOY_CFG_FOLDER/users.cfg
fi |
egrep "^ *\b$key\b *=" |
head -1 | cut -f2 -d'=' |
sed 's/^[ "'']*//g' |
sed 's/[ ",'']*$//g' )
if [ -n "$value" ]; then
echo $value
return
else
echo 'NA'
return
fi
}
branch_name=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
user="$(getCurrentUser)"
read -p "[$branch_name] Commit: " msg
read -p "Push [Y/n]: " yn
yn=${yn:-'Y'}
if [[ "$user" == "NA" ]]; then
git commit --author="$user" -m "$msg"
else
git commit -m "$msg"
fi
case $yn in
[Yy]* ) bash push.sh;;
esac