Last active
August 29, 2015 14:16
-
-
Save Achimh3011/24cf8f10502f63fd138f to your computer and use it in GitHub Desktop.
Check whether the newly pulled revisions are marked with a special keyword
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
#!/usr/bin/env python3 | |
import subprocess | |
import sys | |
PATTERN = 'MY-SPECIAL-COMMIT-MARKER' | |
with subprocess.Popen(['git', 'reflog'], stdout=subprocess.PIPE) as proc: | |
lines = proc.stdout.readlines() | |
new, old = [l.decode().split()[0] for l in lines[:2]] | |
with subprocess.Popen(['git', 'log', '--grep', PATTERN, '%s..%s' % (old, new)], stdout=subprocess.PIPE) as proc: | |
output = proc.stdout.read() | |
if output: | |
print('Found', PATTERN, file=sys.stderr) | |
# you action here | |
else: | |
print('Nothing found...', file=sys.stderr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment