Skip to content

Commit 18fab96

Browse files
authored
Merge pull request #9 from aviskarkc10/master
2 parents bd3cf83 + 894a136 commit 18fab96

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

.ignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hotfix
2+
sprint-11
3+
new-feature
4+
user-story-5

README.md

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

33+
You can create a `.ignore` file in your directory to add custom branches you want to ignore. A `.ignore` file looks like [this](https://github.com/sbimochan/smart-commit/blob/master/.ignore).
34+
3335
## License
3436

3537
[MIT](LICENSE)

commit

100644100755
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,44 @@
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+
15+
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
16+
IGNORED_PATH="./.ignore"
17+
18+
if [ -f "$IGNORED_PATH" ]
19+
then
20+
CUSTOM_BRANCHES=$(cat "$IGNORED_PATH")
21+
BRANCHES=( $CUSTOM_BRANCHES )
22+
IGNORED_BRANCHES=( ${IGNORED_BRANCHES[@]} ${BRANCHES[@]} )
23+
fi
24+
525
CURRENT_BRANCH_CMD="git rev-parse --abbrev-ref HEAD"
626
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)
727

828
COMMIT_WITH_BRANCH="git commit -m \"$CURRENT_BRANCH: $1\""
929
DEFAULT_COMMIT="git commit -m \"$1\""
1030

11-
if [ "$CURRENT_BRANCH" != "dev" ] && [ "$CURRENT_BRANCH" != "master" ] && [ "$CURRENT_BRANCH" != "qa" ] && [ "$CURRENT_BRANCH" != "uat" ] && [ "$CURRENT_BRANCH" != "staging" ]
31+
IS_IGNORED=false
32+
33+
for branch in "${IGNORED_BRANCHES[@]}";
34+
do
35+
if [ "$CURRENT_BRANCH" == $branch ]
36+
then
37+
IS_IGNORED=true
38+
break
39+
fi
40+
done
41+
42+
if [ "$IS_IGNORED" == false ]
1243
then
1344
echo "Commiting with branch name -> $CURRENT_BRANCH"
1445
eval $COMMIT_WITH_BRANCH

0 commit comments

Comments
 (0)