~berfr/commit-history-data-analysis

ref: 52961ab33d317e10dd736f7c3e5c70a038690d45 commit-history-data-analysis/git-csvlog -rwxr-xr-x 584 bytes
52961ab3 — berfr Initial commit 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash

info="
commit hash: %H
author name: %an
author email: %ae
author date: %ad
committer name: %cn
committer email: %ce
committer date: %cd
ref names: %d
subject: %s
"

# TODO: escape occasional newlines in these values
#   body: %b
#   commit notes: %N

info=$(echo "${info}" | sed '1d;$d')
header=$(echo "${info}" | sed -r 's/: %.*/","/' | tr -d '\n' | sed -e 's/..$//' -e 's/^/"/')
placeholders=$(echo "${info}" | sed -r 's/.*: //' | tr '\n' ',' | sed -e 's/,/","/g' -e 's/..$//' -e 's/^/"/')

echo $header
git --no-pager log --pretty=tformat:"$placeholders" "$@"