Last active
October 4, 2024 16:46
-
-
Save cekstam/a7758b8f315835d479f379715eebd0c3 to your computer and use it in GitHub Desktop.
create valid JSON from git log using python and ast.literal_string
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
git log -n 10\ | |
--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; print(json.dumps(ast.literal_eval(sys.stdin.read())))' |
Hi @cekstam, is there a way we can run this to get json for all the commits without mentioning the number like -n 10
?
If I remove the -n
I get errors and no output. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is awesome. Thanks.