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
|
#!/usr/bin/env perl
use strict;
use warnings;
use Pithub::Repos::Commits ();
# https://github.com/kraih/mojo/commit/ad0b3b3fcaacffe39fea34b126cd927e3f02ec78
my $url = $ARGV[0] || die "usage: show_commit.pl <url>\n";
my ( $user, $repo, $sha )
= $url =~ qr{https?://github.com/([^/]+)/([^/]+)/commit/([^/]+)};
my $commit = Pithub::Repos::Commits->new->get(
user => $user,
repo => $repo,
sha => $sha,
);
unless ( $commit->success ) {
die "could not fetch the commit from Github: $url\n";
}
my $c = $commit->content;
print <<EOF;
commit $c->{sha}
Author: $c->{commit}{author}{name} <$c->{commit}{author}{email}>
Date: $c->{commit}{author}{date}
$c->{commit}{message}
EOF
foreach my $f ( @{ $c->{files} } ) {
print <<EOF;
diff --git a/$f->{filename} b/$f->{filename}
$f->{patch}
EOF
}
|