-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfatality
executable file
·56 lines (54 loc) · 1.64 KB
/
fatality
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
#!/bin/bash
# This script takes the branch name in the format WRNNNNN-Other-text
# It strips the WR number out and puts the new wr+message as commit message
# if no errors, it then pushes the current branch up to origin
usage() { # Function: Print a help message.
echo "Usage: $0 [ -n ] [ -h ]" 1>&2
echo "-n: demo, do not process" 1>&2
echo "-h: help, you're reading it" 1>&2
}
exit_abnormal() { # Function: Exit with error.
usage
exit 1
}
while getopts ":nh" options; do
case "${options}" in
n )
demo="yes"
;;
h )
usage
exit 0
;;
esac
done
branch=$(git rev-parse --abbrev-ref HEAD);
githubkey="7a6c5dbf7f8c0f893a6513d8adfe816b689250d2"
username="peterkelly70"
url=$(git config --get remote.origin.url)
#url=$(git config --get remote.origin.url |cut -f3- -d/ );
#url=$(echo "https://${url}");
if [ $branch == "PROD" ]; then
echo "You are on PROD branch, no commits allowed";
elif [[ "$branch" != WR* ]]; then
echo "Branch name '$branch' is incorrect format."
echo "Needs format:WRNNNN-Some-Text";
else
message=$(echo "$branch"|cut -d- -f2-);
wr=$(echo "$branch"|cut -d- -f1);
wr=$(echo "[#$wr]")
#echo "git commit -m \"$wr $message\"";
if [ "$demo" == "yes" ];
then
echo git commit -m "$wr $message";
echo git push -u ${url} ${branch};
echo git status
else
#echo process loop
if git commit -m "$wr $message"
then
git push -u ${url} ${branch};
fi
fi
fi
exit 0