Skip to content
Merged
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
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is good.


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