Skip to content

Instantly share code, notes, and snippets.

@pellepim
Created June 6, 2022 15:08
Show Gist options
  • Save pellepim/d9ec59b854e77c70fb2663d361a67e01 to your computer and use it in GitHub Desktop.
Save pellepim/d9ec59b854e77c70fb2663d361a67e01 to your computer and use it in GitHub Desktop.
Pretty print author's git log to JSON
git log --author="AUTHOR"\
--pretty=format:'{"commit": "%H", "author": "%aN <%aE>", "date": "%ai", "message": """%B""", "notes": """%N""" },' \
$@ | awk 'BEGIN { print("[") } { print($0) } END { print("]") }' | \
python -u -c 'import ast,json,sys; fp = open("gitlog.json", "w"); \
fp.write(json.dumps(ast.literal_eval(sys.stdin.read()), indent=2, sort_keys=True)); fp.close()'
@pellepim
Copy link
Author

pellepim commented Jun 6, 2022

Gets a pretty printed JSON file containing info about a certain author's commits (all of them) in a repo.

Adapted from https://gist.github.com/cekstam/a7758b8f315835d479f379715eebd0c3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment