Skip to content

Instantly share code, notes, and snippets.

@Achimh3011
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Achimh3011/24cf8f10502f63fd138f to your computer and use it in GitHub Desktop.
Save Achimh3011/24cf8f10502f63fd138f to your computer and use it in GitHub Desktop.
Check whether the newly pulled revisions are marked with a special keyword
#!/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