-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommit-json
More file actions
executable file
·42 lines (39 loc) · 1.35 KB
/
commit-json
File metadata and controls
executable file
·42 lines (39 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
wt="$1"
gd="$2"
branch="$3"
IFS='' read -r -d '' FORMAT << 'EOF'
{
^^^^author^^^^: { ^^^^name^^^^: ^^^^%aN^^^^,
^^^^email^^^^: ^^^^%aE^^^^,
^^^^date^^^^: ^^^^%aD^^^^,
^^^^dateISO8601^^^^: ^^^^%aI^^^^},
^^^^body^^^^: ^^^^%b^^^^,
^^^^commitHash^^^^: ^^^^%H^^^^,
^^^^commitHashAbbreviated^^^^: ^^^^%h^^^^,
^^^^committer^^^^: {
^^^^name^^^^: ^^^^%cN^^^^,
^^^^email^^^^: ^^^^%cE^^^^,
^^^^date^^^^: ^^^^%cD^^^^,
^^^^dateISO8601^^^^: ^^^^%cI^^^^},
^^^^encoding^^^^: ^^^^%e^^^^,
^^^^notes^^^^: ^^^^%N^^^^,
^^^^parent^^^^: ^^^^%P^^^^,
^^^^parentAbbreviated^^^^: ^^^^%p^^^^,
^^^^refs^^^^: ^^^^%D^^^^,
^^^^signature^^^^: {
^^^^key^^^^: ^^^^%GK^^^^,
^^^^signer^^^^: ^^^^%GS^^^^,
^^^^verificationFlag^^^^: ^^^^%G?^^^^},
^^^^subject^^^^: ^^^^%s^^^^,
^^^^subjectSanitized^^^^: ^^^^%f^^^^,
^^^^tree^^^^: ^^^^%T^^^^,
^^^^treeAbbreviated^^^^: ^^^^%t^^^^
},
EOF
FORMAT=$(echo "$FORMAT"|tr -d '\r\n ')
git --work-tree="$wt" --git-dir="$gd" log --pretty=format:"$FORMAT" "$branch" | \
sed -e ':a' -e 'N' -e '$!ba' -e s'/\^^^^},\n{\^^^^/^^^^},{^^^^/g' \
-e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/\^^^^/"/g' -e '$ s/,$//' | \
sed -e ':a' -e 'N' -e '$!ba' -e 's/\r//g' -e 's/\n/\\n/g' -e 's/\t/\\t/g' | \
awk 'BEGIN { ORS=""; printf("[") } { print($0) } END { printf("]\n") }'