Skip to content

Instantly share code, notes, and snippets.

@rishabhbhardwaj
Last active July 6, 2016 04:57
Show Gist options
  • Save rishabhbhardwaj/179d73ae0cf12bfe67f234b39ca194df to your computer and use it in GitHub Desktop.
Save rishabhbhardwaj/179d73ae0cf12bfe67f234b39ca194df to your computer and use it in GitHub Desktop.
Parse Git Logs to Json
import os
import sys
args = sys.argv
l = len(args)
if l == 1:
repoPath = "."
elif l == 2:
repoPath = args[1]
else:
raise RuntimeError('Bad Arguments')
gitLogCmd = "git log --pretty=format:'{%n \"commit\": \"%H\",%n \"author\": \"%an <%ae>\",%n \"date\": \"%ad\",%n \"message\": \"%f\"%n},'"
commitLogs = os.popen("cd " + repoPath + " && " + gitLogCmd).read()
commitLogs = "[" + commitLogs.rstrip(",") + "]"
print commitLogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment