Skip to content

Commit dfc2663

Browse files
authored
Merge pull request #6 from aviskarkc10/master
Allow people to add custom branches
2 parents 2336cdc + dff919e commit dfc2663

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ $ commit "New feature"
3030
git commit -m "New feature"
3131
```
3232

33+
You can create a file `.ignore` in your directory to add custom branches you want to ignore. Example `.ignore` file:
34+
35+
```
36+
hot-fix
37+
sprint-11
38+
new-feature
39+
```
40+
3341
## License
3442

3543
[MIT](LICENSE)

commit

100644100755
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,33 @@
22

33
echo 'Running commit script'
44

5+
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
6+
7+
IGNORED_PATH="./.ignore"
8+
if [ -f "$IGNORED_PATH" ]
9+
then
10+
CUSTOM_BRANCHES=$(cat "$IGNORED_PATH")
11+
BRANCHES=( $CUSTOM_BRANCHES )
12+
IGNORED_BRANCHES=( ${IGNORED_BRANCHES[@]} ${BRANCHES[@]} )
13+
fi
14+
515
CURRENT_BRANCH_CMD="git rev-parse --abbrev-ref HEAD"
616
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)
717

818
COMMIT_WITH_BRANCH="git commit -m \"$CURRENT_BRANCH: $1\""
919
DEFAULT_COMMIT="git commit -m \"$1\""
20+
IS_IGNORED=false
21+
22+
for branch in "${IGNORED_BRANCHES[@]}";
23+
do
24+
if [ "$CURRENT_BRANCH" == $branch ]
25+
then
26+
IS_IGNORED=true
27+
break
28+
fi
29+
done
1030

11-
if [ "$CURRENT_BRANCH" != "dev" ] && [ "$CURRENT_BRANCH" != "master" ] && [ "$CURRENT_BRANCH" != "qa" ] && [ "$CURRENT_BRANCH" != "uat" ] && [ "$CURRENT_BRANCH" != "staging" ]
31+
if [ "$IS_IGNORED" == false ]
1232
then
1333
echo "Commiting with branch name -> $CURRENT_BRANCH"
1434
eval $COMMIT_WITH_BRANCH

0 commit comments

Comments
 (0)