-
Notifications
You must be signed in to change notification settings - Fork 8
/
commit
executable file
·74 lines (64 loc) · 1.41 KB
/
commit
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Script to 'wrap' around git and update ChangeLog and version / date in file.
COMMITFILE="none"
COMMITMSG="none"
COMMITTYPE="none"
BUMP="false"
PUSH="false"
ALL="true"
# Parse CLI arguments / options
USAGE1="commit [-F <filename>] [-m <text>] [-p] [-b] [-o]"
while getopts "F:m:bpo" options; do
case $options in
F ) COMMITFILE=$OPTARG
COMMITTYPE="file"
echo "Using file "$COMMITFILE" for commit message.";;
m ) COMMITMSG=$OPTARG
COMMITTYPE="msg"
echo "Using supplied text for commit message.";;
b ) BUMP="true"
echo "Version (patch) number will be bumped.";;
o ) ALL="false"
echo "Only specific changes will be committed.";;
p ) PUSH="true"
echo "Files will be committed and local changes pushed to server.";;
\? ) echo -e $USAGE1
exit 1;;
* ) echo -e $USAGE1
exit 1;;
esac
done
# Set up flags to pass
FLAGS=""
if [ "$ALL" = "true" ]
then
FLAGS="$FLAGS -a"
fi
# Check that a commit type was given
if [ "$COMMITTYPE" = "none" ]
then
echo "No commit message/file was given."
exit 0
fi
# Bump version if requested
if [ "$BUMP" = "true" ]
then
./changeversion bump
else
./changeversion
fi
# Commit changes
if [ "$COMMITTYPE" = "file" ]
then
git commit $FLAGS -F $COMMITFILE
fi
if [ "$COMMITTYPE" = "msg" ]
then
git commit $FLAGS -m "$COMMITMSG"
fi
# Push changes to server?
if [ "$PUSH" = "true" ]
then
git push origin master --tags
fi
exit 0