Skip to content

Instantly share code, notes, and snippets.

@richo
Created February 4, 2013 01:04
Show Gist options
  • Save richo/4704477 to your computer and use it in GitHub Desktop.
Save richo/4704477 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import os
import sys
import re
COMMIT_RE = re.compile("commit ([a-f0-9]{40})")
GEOTAG_RE = re.compile("richo_geotag: ([-0-9.]+,[-0-9.]+)")
def usage():
sys.stderr.write("Usage: %s <tags_file>\n" % (sys.argv[0]))
sys.stderr.write("tags_file should be a file of commits and tags")
os.exit(1)
def main(f):
fh = open(f, 'r')
last = ""
for line in fh:
line = line.strip()
if last:
commit_match = COMMIT_RE.match(last)
if commit_match:
geotag_match = GEOTAG_RE.match(line)
if geotag_match:
print("%s %s" % (commit_match.groups(1)[0], geotag_match.groups(1)[0]))
last = ""
else:
last = line
if __name__ == "__main__":
if len(sys.argv) == 1:
usage()
main(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment