Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .smart-commit-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hotfix
sprint-11
new-feature
user-story-5
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@ curl https://raw.githubusercontent.com/sbimochan/smart-commit/master/commit -o /

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

```shell
$ commit "New feature"
```shell
$ commit "New feature"

# translates to
git commit -m "EF-803: New feature"
```
# translates to
git commit -m "EF-803: New feature"
```

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

```shell
$ commit "New feature"
```shell
$ commit "New feature"

# translates to
git commit -m "New feature"
```
# translates to
git commit -m "New feature"
```

## Skip Branches

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).

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).
Additionally, you might want to add `.smart-commit-ignore` to your `.gitignore` file.

## License

Expand Down
18 changes: 9 additions & 9 deletions commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

echo 'Running commit script'

IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
IGNORED_PATH="./.ignore"
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
CUSTOM_IGNORED_PATH="$GIT_ROOT_DIRECTORY/.smart-commit-ignore"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is CUSTOM_IGNORED_PATH only declared and not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, is it? I think I tested it myself. This might be a blunder. 😞

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your test passed because we have fallback array of branches 😂


if [ -f "$IGNORED_PATH" ]
if [ -f "$CUSTOM_IGNORED_PATH" ]
then
CUSTOM_BRANCHES=$(cat "$IGNORED_PATH")
BRANCHES=( $CUSTOM_BRANCHES )
IGNORED_BRANCHES=( ${IGNORED_BRANCHES[@]} ${BRANCHES[@]} )
fi
CUSTOM_BRANCHES=$(cat "$CUSTOM_IGNORED_PATH")
BRANCHES=($CUSTOM_BRANCHES)
IGNORED_BRANCHES=(${IGNORED_BRANCHES[@]} ${BRANCHES[@]})
fi

CURRENT_BRANCH_CMD="git rev-parse --abbrev-ref HEAD"
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)
Expand All @@ -19,7 +20,7 @@ COMMIT_WITH_BRANCH="git commit -m \"$CURRENT_BRANCH: $1\""
DEFAULT_COMMIT="git commit -m \"$1\""

IS_IGNORED=false

for branch in "${IGNORED_BRANCHES[@]}";
do
if [ "$CURRENT_BRANCH" == $branch ]
Expand All @@ -34,6 +35,5 @@ then
echo "Commiting with branch name -> $CURRENT_BRANCH"
eval $COMMIT_WITH_BRANCH
else
echo "Commiting with default branch"
eval $DEFAULT_COMMIT
fi