]>
Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-push-log
3 # Show reflog information for all branch heads by date. This is useful on bare
4 # remotes to determine when / who pushed and when.
7 # change into git reflog dir to make everything easier
8 ENV['GIT_DIR'] ||= `git rev-parse --git-dir`.chomp
9 Dir
.chdir(ENV['GIT_DIR'] +
'/logs/refs/heads')
11 # find all reflog files
12 logs
= Dir
['**'].select
{ |f
| File
.file
?(f
) }
14 # build master list of all reflog entries for all refs
17 entries
= File
.read(log
).split("\n")
18 entries
.each
do |line
|
19 before
, after
, rest
= line
.split(' ', 3)
20 push_info
, message
= rest
.split("\t", 1)
21 if push_info
=~
/^(.*?) (<.*>) (\d+) ([0-9+-]+)/
22 name
, email
, timestamp
, offset
= $1, $2, $3.to_i
, $4
23 date
= Time
.at(timestamp
)
25 records
<< [log
, before
, after
, name
, email
, date
]
29 # sort and output reflog entries with some formatting
31 records
= records
.sort_by
{ |r
| r
.last
}.reverse
32 records
.each
do |ref
, before
, after
, name
, email
, date
|
33 printf
"%-20s %7s:%7s %-30s %s\n",
34 date
.iso8601
, before
[0,7], after
[0,7], ref
, email