Skip to content

Instantly share code, notes, and snippets.

@bavovna
Created October 24, 2013 19:39
Show Gist options
  • Save bavovna/7143639 to your computer and use it in GitHub Desktop.
Save bavovna/7143639 to your computer and use it in GitHub Desktop.
import sys
from subprocess import Popen, PIPE
def git_history(commit_from, commit_to):
cmd=["git", "log", "--pretty=oneline", "--grep", "'[[:digit:]]\{2,\}'", "--grep", "'issue\|feature\|bug'", "--max-parents=1", "{}...{}".format(commit_from, commit_to)]
cmd = " ".join(cmd)
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
return p.communicate()
def commits(commit_from, commit_to):
out, err = git_history(commit_from, commit_to)
if len(err):
for l in err.split('\n'):
print l
sys.exit(1)
for commit in out.split('\n'):
yield commit
if __name__ == '__main__':
commit_from = sys.argv[1]
commit_to = sys.argv[2]
for commit in commits(commit_from, commit_to):
print commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment