Skip to content

Instantly share code, notes, and snippets.

@spelufo
Created November 7, 2024 17:33
Show Gist options
  • Save spelufo/5897f547173eeead0f2b3b819afbee7c to your computer and use it in GitHub Desktop.
Save spelufo/5897f547173eeead0f2b3b819afbee7c to your computer and use it in GitHub Desktop.
Convert git log output to JSON
# Similar to https://til.simonwillison.net/jq/git-log-json
git log --pretty=format:'%H%x00%an <%ae>%x00%ad%x00%s%x00' | python -c 'import sys, json
for line in sys.stdin:
commit, author, date, *message = line.split("\x00")
print(json.dumps({"commit": commit, "author": author, "date": date, "message": message[0]}))
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment