Skip to content

Instantly share code, notes, and snippets.

@mgamer
mgamer / pre-commit
Last active January 9, 2017 10:35 — forked from DerLobi/pre-commit
Don't commit focused tests. Use this as a pre-commit hook and all staged changes that contain `fdescribe`, `fcontext`, `fit`, `fspecify` or `fexample` will be replaced with `describe`, `context`, `it` or `example`. Copy this file as `pre-commit` into the `.git/hooks` folder of your repository (create it if neccessary) and chmod +x the file.
#!/bin/sh
#adapted from https://gist.github.com/mgamer/132534fe1155fb40adc5adfc58790373
DESCRIBEFILES=$(git diff --staged -G"^\s*fdescribe\(" --name-only | wc -l)
if [ $DESCRIBEFILES -gt 0 ]
then
echo "You forgot to remove a fdescribe in the following files:"
git --no-pager diff --staged --name-only -G"^\s*fdescribe\(" | xargs -L1 -I {} sh -c 'sed -i "" "s/\s*fdescribe(/describe(/g" {}; git add "{}"'
echo "This is fixed automatically now"