Skip to content

Commit 70e6dae

Browse files
committed
git: Add a command to log to JSON
See https://til.simonwillison.net/jq/git-log-json.
1 parent fa45b81 commit 70e6dae

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

git/git-log-json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
# See https://til.simonwillison.net/jq/git-log-json.
4+
5+
git log --pretty=format:'%H%x00%an <%ae>%x00%ad%x00%s%x00' | \
6+
jq -R -s '[split("\n")[:-1] | map(split("\u0000")) | .[] | {
7+
"commit": .[0],
8+
"author": .[1],
9+
"date": .[2],
10+
"message": .[3]
11+
}]'

0 commit comments

Comments
 (0)