Created
July 18, 2012 13:19
-
-
Save stubb/3136167 to your computer and use it in GitHub Desktop.
A git post-commit hook which searches for deleted .py files in HEAD and removes the corresponding .pyc files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# This post commit hook searches for deleted .py files in HEAD and removes the | |
# corresponding .pyc files. | |
# | |
deleted_files = 'git show --pretty="format:" --name-only HEAD --diff-filter=D' | |
for i in ${deleted_files[@]}; do | |
file_ending=$(echo $i | grep -o "...$") | |
if [ $file_ending == '.py' ] ; then | |
rm ${i}c | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment