Skip to content

Instantly share code, notes, and snippets.

@shouhei
Last active December 24, 2016 00:32
Show Gist options
  • Save shouhei/c45422fc049ee827deb94bbbb2769fe2 to your computer and use it in GitHub Desktop.
Save shouhei/c45422fc049ee827deb94bbbb2769fe2 to your computer and use it in GitHub Desktop.
コミット前にブランチ名確認する君
#! /bin/sh
GIT_BRANCHES=`git branch | rev | cut -d ' ' -f1 | rev`
for BRANCH in $GIT_BRANCHES
do
if [[ $BRANCH =~ "-" ]]; then
printf "\e[31m$BRANCH does not keep naming rules.\e[m\n"
printf "\e[31mPlease check your branch naming.\e[m\n"
echo 'git branch -m $NEW $OLD'
exit 1
fi
done
printf -e "\e[32mAll branch name are fine.\e[m\n"
exit 0
#! /bin/sh
GIT_BRANCHES=`git branch | rev | cut -d ' ' -f1 | rev`
for BRANCH in $GIT_BRANCHES
do
if [[ $BRANCH =~ "-" ]]; then
git branch -m $BRANCH ${BRANCH/-/_}
fi
done
printf "\e[32mAll branch name are fine.\e[m\n"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment