Skip to content

Instantly share code, notes, and snippets.

@baflo
Last active August 2, 2019 06:04
Show Gist options
  • Save baflo/d22e9de7be3e6d52e2ae27e42dea0d21 to your computer and use it in GitHub Desktop.
Save baflo/d22e9de7be3e6d52e2ae27e42dea0d21 to your computer and use it in GitHub Desktop.
Some git
# Git hook to prevent focused tests/specs (fdescribe, fit)
red='\033[0;31m'
no_color='\033[0m'
focused_spec_findings=$(git grep --cached -nIE "^\s*f(describe|it)\b")
if [ ! -z "$focused_spec_findings" ]
then
# Redirect output to stderr.
exec 1>&2
echo ${red}You still got some focused tests \(fdescribe, fit, etc.\), please clean these before committing:${no_color}
echo
echo Files:
echo "$(echo "$focused_spec_findings" | sed 's/^/# /')"
echo
exit 1
fi
# Adds git alias `delete-merged-branches`, which suggests a list of branches that are already merged and should be deleted, then deletes them.
# `vipe` requires the `moreutils` package
git config alias.delete-merged-branches '!git branch --merged | grep -vE "(^\s*(master|develop)\s*$|^\*)" | EDITOR=nano vipe | xargs git branch -d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment