Skip to content

Commit f043e3b

Browse files
committed
Resolve conflicts
2 parents efee641 + 09576c4 commit f043e3b

File tree

5 files changed

+74
-39
lines changed

5 files changed

+74
-39
lines changed

.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
File renamed without changes.

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![smart commit logo](assets/logo.svg)
2+
13
# Smart Commit
24

35
Create a commit prefixed with the current branch name.
@@ -14,23 +16,34 @@ curl https://raw.githubusercontent.com/sbimochan/smart-commit/master/commit -o /
1416

1517
* If your current branch name is `EF-803`
1618

17-
```shell
18-
$ commit "New feature"
19+
```shell
20+
$ commit "New feature"
1921

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

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

26-
```shell
27-
$ commit "New feature"
28+
```shell
29+
$ commit "New feature"
2830

29-
# translates to
30-
git commit -m "New feature"
31-
```
31+
# translates to
32+
git commit -m "New feature"
33+
```
34+
35+
## Skip Branches
36+
37+
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).
38+
39+
Additionally, you might want to add `.smart-commit-ignore` to your `.gitignore` file.
40+
41+
## Contributors
3242

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).
43+
1. [Aviskar KC](https://github.com/aviskarkc10)
44+
2. [Robus Gauli](https://github.com/RobusGauli)
45+
3. [Saroj Shahi](http://sarojshahi.com.np/)
46+
4. [Saugat Acharya](https://github.com/mesaugat)
3447

3548
## License
3649

assets/logo.svg

Lines changed: 8 additions & 0 deletions
Loading

commit

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
echo 'Running commit script'
4-
5-
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
6-
IGNORED_PATH="./.ignore"
7-
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
4+
if [ -z "${1:-}" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
5+
echo "Create a commit prefixed with the current branch name."
6+
echo
7+
echo "Usage:"
8+
echo " commit MESSAGE"
9+
echo
10+
echo "Example:"
11+
echo " commit \"Hello world!\""
12+
exit 1
13+
fi
1414

15-
CURRENT_BRANCH_CMD="git symbolic-ref --short HEAD"
16-
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)
15+
CURRENT_BRANCH="$(git symbolic-ref --short HEAD)"
16+
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
17+
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
18+
CUSTOM_IGNORED_PATH="$GIT_ROOT_DIRECTORY/.smart-commit-ignore"
1719

18-
COMMIT_WITH_BRANCH="git commit -m \"$CURRENT_BRANCH: $1\""
19-
DEFAULT_COMMIT="git commit -m \"$1\""
20+
if [ -f "$CUSTOM_IGNORED_PATH" ]; then
21+
CUSTOM_BRANCHES=$(cat "$CUSTOM_IGNORED_PATH")
22+
BRANCHES=($CUSTOM_BRANCHES)
23+
IGNORED_BRANCHES=(${IGNORED_BRANCHES[@]} ${BRANCHES[@]})
24+
fi
2025

2126
IS_IGNORED=false
22-
23-
for branch in "${IGNORED_BRANCHES[@]}";
24-
do
25-
if [ "$CURRENT_BRANCH" == $branch ]
26-
then
27-
IS_IGNORED=true
28-
break
27+
28+
for branch in "${IGNORED_BRANCHES[@]}"; do
29+
if [ "$CURRENT_BRANCH" == $branch ]; then
30+
IS_IGNORED=true
31+
break
2932
fi
3033
done
3134

32-
if [ "$IS_IGNORED" == false ]
33-
then
34-
echo "Commiting with branch name -> $CURRENT_BRANCH"
35-
eval $COMMIT_WITH_BRANCH
35+
if [ "$IS_IGNORED" == false ]; then
36+
# Edit your config here
37+
git commit -m "$CURRENT_BRANCH: $1"
3638
else
37-
echo "Commiting with default branch"
38-
eval $DEFAULT_COMMIT
39+
git commit -m "$1"
3940
fi

0 commit comments

Comments
 (0)