File tree Expand file tree Collapse file tree 1 file changed +17
-11
lines changed
Expand file tree Collapse file tree 1 file changed +17
-11
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -euo pipefail
33
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
14+
415CURRENT_BRANCH=" $( git rev-parse --abbrev-ref HEAD) "
516GIT_ROOT_DIRECTORY=$( git rev-parse --show-toplevel)
617IGNORED_BRANCHES=(" dev" " master" " qa" " uat" " staging" )
718CUSTOM_IGNORED_PATH=" $GIT_ROOT_DIRECTORY /.smart-commit-ignore"
819
9- if [ -f " $CUSTOM_IGNORED_PATH " ]
10- then
20+ if [ -f " $CUSTOM_IGNORED_PATH " ]; then
1121 CUSTOM_BRANCHES=$( cat " $CUSTOM_IGNORED_PATH " )
1222 BRANCHES=($CUSTOM_BRANCHES )
1323 IGNORED_BRANCHES=(${IGNORED_BRANCHES[@]} ${BRANCHES[@]} )
1424fi
1525
1626IS_IGNORED=false
1727
18- for branch in " ${IGNORED_BRANCHES[@]} " ;
19- do
20- if [ " $CURRENT_BRANCH " == $branch ]
21- then
22- IS_IGNORED=true
23- break
28+ for branch in " ${IGNORED_BRANCHES[@]} " ; do
29+ if [ " $CURRENT_BRANCH " == $branch ]; then
30+ IS_IGNORED=true
31+ break
2432 fi
2533done
2634
27-
28- if [ " $IS_IGNORED " == false ]
29- then
35+ if [ " $IS_IGNORED " == false ]; then
3036 # Edit your config here
3137 git commit -m " $CURRENT_BRANCH : $1 "
3238else
You can’t perform that action at this time.
0 commit comments