Skip to content

Instantly share code, notes, and snippets.

@celeen
Last active August 29, 2015 14:13
Show Gist options
  • Save celeen/90992a635f42eb87534a to your computer and use it in GitHub Desktop.
Save celeen/90992a635f42eb87534a to your computer and use it in GitHub Desktop.
commit-hook for finding text
#!/usr/bin/env python
import sys, os, re
import subprocess
diff = subprocess.check_output(['git', 'diff', 'HEAD'])
def check_for_text(text, diff):
exp = re.compile(text)
match = exp.search(diff)
if match:
print "Please remove the '@sandbox' tag"
sys.exit(1)
else:
sys.exit(0)
check_for_text('\+.*(?P<sandbox>(?<!")@sandbox)', diff)
@celeen
Copy link
Author

celeen commented Jan 22, 2015

Maybe not the most effective, but I wanted to practice/keep learning python.

@celeen
Copy link
Author

celeen commented Jan 29, 2015

updated the pre-commit so that it ignores any @sandbox tags that are immediately preceded by a "
presumably, these are in runner files, and haven't been left in the repo by accident

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment