Skip to content

Commit 3098780

Browse files
committed
Remove color echo and extra verbosity
2 parents c92d40a + 1f57ad0 commit 3098780

4 files changed

Lines changed: 49 additions & 37 deletions

File tree

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.smart-commit-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: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,33 @@ curl https://raw.githubusercontent.com/sbimochan/smart-commit/master/commit -o /
1414

1515
* If your current branch name is `EF-803`
1616

17-
```shell
18-
$ commit "New feature"
17+
```shell
18+
$ commit "New feature"
1919

20-
# translates to
21-
git commit -m "EF-803: New feature"
22-
```
20+
# translates to
21+
git commit -m "EF-803: New feature"
22+
```
2323

2424
* If your current branch is either of `dev`, `uat`, `qa`, `staging` or `master`
2525

26-
```shell
27-
$ commit "New feature"
26+
```shell
27+
$ commit "New feature"
2828

29-
# translates to
30-
git commit -m "New feature"
31-
```
29+
# translates to
30+
git commit -m "New feature"
31+
```
32+
33+
## Skip Branches
34+
35+
To add a custom branch that you would like to skip, create a `.smart-commit-ignore` file in your top level directory. A `.smart-commit-ignore` file looks like [this](https://github.com/sbimochan/smart-commit/blob/master/.smart-commit-ignore).
36+
37+
Additionally, you might want to add `.smart-commit-ignore` to your `.gitignore` file.
38+
39+
## Contributors
3240

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).
41+
1. [Aviskar KC](https://github.com/aviskarkc10)
42+
2. [Robus Gauli](https://github.com/RobusGauli)
43+
3. [Saugat Acharya](https://github.com/mesaugat)
3444

3545
## License
3646

commit

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
IS_IGNORED=false
5-
IGNORED_PATH="./.ignore"
64
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
5+
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
76
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
7+
CUSTOM_IGNORED_PATH="$GIT_ROOT_DIRECTORY/.smart-commit-ignore"
88

9-
colorEcho(){
10-
RED="\033[0;31m"
11-
GREEN='\033[0;32m'
12-
YELLOW='\033[1;33m'
13-
NO_COLOR='\033[0m'
14-
printf "${!1}${2} ${NO_COLOR}\n"
15-
}
16-
17-
commitWithBranch() {
18-
colorEcho "GREEN" "Commit translation: \"$CURRENT_BRANCH: $1\""
19-
# Edit your config here
20-
git commit -m "$CURRENT_BRANCH: $1"
21-
}
22-
23-
if [[ -f "$IGNORED_PATH" ]]
9+
if [ -f "$CUSTOM_IGNORED_PATH" ]
2410
then
25-
CUSTOM_BRANCHES=$(cat "$IGNORED_PATH")
26-
BRANCHES=( $CUSTOM_BRANCHES )
27-
IGNORED_BRANCHES=( ${IGNORED_BRANCHES[@]} ${BRANCHES[@]} )
28-
colorEcho "YELLOW" "Excluding branches from .ignore file."
29-
else
30-
colorEcho "YELLOW" ".ignore file not found, excluding default branches."
11+
CUSTOM_BRANCHES=$(cat "$CUSTOM_IGNORED_PATH")
12+
BRANCHES=($CUSTOM_BRANCHES)
13+
IGNORED_BRANCHES=(${IGNORED_BRANCHES[@]} ${BRANCHES[@]})
3114
fi
3215

33-
for branch in "${IGNORED_BRANCHES[@]}"
16+
IS_IGNORED=false
17+
18+
for branch in "${IGNORED_BRANCHES[@]}";
3419
do
3520
if [ "$CURRENT_BRANCH" == $branch ]
3621
then
@@ -42,8 +27,8 @@ done
4227

4328
if [ "$IS_IGNORED" == false ]
4429
then
45-
commitWithBranch $1
30+
# Edit your config here
31+
git commit -m "$CURRENT_BRANCH: $1"
4632
else
47-
colorEcho "GREEN" "Commit translation: \"$1\""
4833
git commit -m "$1"
4934
fi

0 commit comments

Comments
 (0)