Skip to content

Commit ecb0bb0

Browse files
committed
Use a for loop to check if branch name should be ignored
1 parent c4fa88d commit ecb0bb0

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

.commit.swp

12 KB
Binary file not shown.

commit

100644100755
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
#!/usr/bin/env bash
22
echo 'Running commit script'
3+
4+
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
5+
36
CURRENT_BRANCH_CMD="git rev-parse --abbrev-ref HEAD"
47
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)
58

69
COMMIT_WITH_BRANCH="git commit -m \"$CURRENT_BRANCH: $1\""
710
DEFAULT_COMMIT="git commit -m \"$1\""
11+
IS_IGNORED=false
12+
13+
for branch in "${IGNORED_BRANCHES[@]}";
14+
do
15+
if [ "$CURRENT_BRANCH" == ignore ]
16+
then
17+
IS_IGNORED=true
18+
break
19+
fi
20+
done
821

9-
if [ "$CURRENT_BRANCH" != "dev" ] && [ "$CURRENT_BRANCH" != "master" ] && [ "$CURRENT_BRANCH" != "qa" ] && [ "$CURRENT_BRANCH" != "uat" ] && [ "$CURRENT_BRANCH" != "staging" ]
22+
if [ "$IS_IGNORED" == false ]
1023
then
1124
echo "Commiting with branch name-> $CURRENT_BRANCH"
1225
eval $COMMIT_WITH_BRANCH

ignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dev
2+
uat
3+
master
4+
EF-223

0 commit comments

Comments
 (0)