Skip to content

Instantly share code, notes, and snippets.

@steinkel
Created March 31, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steinkel/59dd3490793ac424dac3d806521cae0c to your computer and use it in GitHub Desktop.
Save steinkel/59dd3490793ac424dac3d806521cae0c to your computer and use it in GitHub Desktop.
my git commit alias
# Installation: add this to your .bash_aliases or .zshrc
# change the following line to point your phpcbf preferred tool
alias phpcbf3="/home/steinkel/phpcs-cake3/vendor/bin/phpcbf --standard=CakePHP"
# gitco function
# allow commit and comment with no quotes
# adds refs #id based on current feature/issue/hotfix branch
# run phpcbf on touched files
function gitco () {
revision=`git rev-parse --abbrev-ref HEAD | sed -n '/feature\//s///p'`
if [[ ! $revision ]]
then
revision=`git rev-parse --abbrev-ref HEAD | sed -n '/issue\//s///p'`
fi
if [[ ! $revision ]]
then
revision=`git rev-parse --abbrev-ref HEAD | sed -n '/hotfix\//s///p'`
fi
if [[ ! $revision ]]
then
git commit -m "$*"
else
git commit -m "refs #$revision $*"
fi
if [ -d "src" ]; then
phpcbf3 `git diff-tree --no-commit-id --name-only -r HEAD`
git add `git diff-tree --no-commit-id --name-only -r HEAD` && git commit -m 'fix cs'
fi
}
function gitme () {
git merge --no-ff "$1"
}
export gitme
export gitco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment