5
use lib $ENV{GL_LIBDIR};
9
Usage: ssh git@host who-pushed <repo> <SHA>
11
Determine who pushed the given commit. The first few hex digits of the SHA
14
Each line of the output contains the following fields: timestamp, a
15
transaction ID, username, refname, and the old and new SHAs for the ref.
17
We assume the logfile names have been left as default, or if changed, in such
18
a way that they come up oldest first when sorted.
20
The program searches ALL the log files, in reverse sorted order (i.e., newest
21
first). This means it could take a long time if your log directory is large
22
and contains lots of old log files. Patches to limit the search to an
23
optional date range are welcome.
25
Note on the "transaction ID" field: if looking at the log file doesn't help
26
you figure out what its purpose is, please just ignore it.
29
usage() if not @ARGV or @ARGV < 2 or $ARGV[0] eq '-h';
30
usage() if $ARGV[1] !~ /^[0-9a-f]+$/i;
33
my $sha = shift; $sha =~ tr/A-F/a-f/;
35
$ENV{GL_USER} and ( can_read($repo) or die "no read permissions on '$repo'" );
37
# ----------------------------------------------------------------------
39
my $repodir = "$ENV{GL_REPO_BASE}/$repo.git";
40
chdir $repodir or die "repo '$repo' missing";
41
(my $logdir = $ENV{GL_LOGFILE}) =~ s(/[^/]+$)();
43
for my $logfile ( reverse glob("$logdir/*") ) {
45
for my $line ( reverse grep { m(\tupdate\t($repo|$repodir)\t) } <> ) {
47
my @fields = split /\t/, $line;
48
my ($ts, $pid, $who, $ref, $d_old, $new) = @fields[ 0, 1, 4, 6, 7, 8];
50
# d_old is what you display
52
$old = "" if $d_old eq ("0" x 40);
53
$old = "$old.." if $old;
55
system("git rev-list $old$new 2>/dev/null | grep ^$sha >/dev/null && echo '$ts $pid $who $ref $d_old $new'");