Skip to content

Commit

Permalink
Merge pull request #12 from sbimochan/enhancement
Browse files Browse the repository at this point in the history
Enhancing... Color echo and code cleanups
  • Loading branch information
sbimochan authored Jan 13, 2019
2 parents 1f57ad0 + 3098780 commit a91c163
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -euo pipefail

echo 'Running commit script'

CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
GIT_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
IGNORED_BRANCHES=("dev" "master" "qa" "uat" "staging")
CUSTOM_IGNORED_PATH="$GIT_ROOT_DIRECTORY/.smart-commit-ignore"
Expand All @@ -13,12 +13,6 @@ then
IGNORED_BRANCHES=(${IGNORED_BRANCHES[@]} ${BRANCHES[@]})
fi

CURRENT_BRANCH_CMD="git rev-parse --abbrev-ref HEAD"
CURRENT_BRANCH=$(eval $CURRENT_BRANCH_CMD)

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

IS_IGNORED=false

for branch in "${IGNORED_BRANCHES[@]}";
Expand All @@ -30,10 +24,11 @@ for branch in "${IGNORED_BRANCHES[@]}";
fi
done


if [ "$IS_IGNORED" == false ]
then
echo "Commiting with branch name -> $CURRENT_BRANCH"
eval $COMMIT_WITH_BRANCH
# Edit your config here
git commit -m "$CURRENT_BRANCH: $1"
else
eval $DEFAULT_COMMIT
git commit -m "$1"
fi

0 comments on commit a91c163

Please sign in to comment.