Last active
July 6, 2016 04:57
-
-
Save rishabhbhardwaj/179d73ae0cf12bfe67f234b39ca194df to your computer and use it in GitHub Desktop.
Parse Git Logs to Json
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
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