Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 48 lines (40 sloc) 1.31 KB
#!/usr/bin/env perl
use strict;
use warnings;
use Cwd qw(realpath);
use File::Basename;
my $BASE_DIR = dirname realpath __FILE__;
use POSIX qw(strftime);
my $users = do "$BASE_DIR/cache/author-data.pl";
my $commit = $ENV{GIT_COMMIT} || exit;
my $commit_message = `git show -s --pretty=raw $commit`;
my %vars;
my @find = $commit_message =~ /r\d+\@([^\n]+)\|\s+([0-9:+ -]+)/g;
if (@find == 2) {
my ($user) = $find[0] =~ /(\w+)\s*$/;
my ($date, $time, $tz) = split / /, $find[1];
my @date = split /-/, $date;
my @time = split /:/, $time;
$date[0] -= 1900;
$date[1]--;
$vars{GIT_AUTHOR_DATE} = strftime('%s', (reverse @time), (reverse @date)) . ' ' . $tz;
if ($users->{$user}) {
$vars{GIT_AUTHOR_NAME} = $users->{$user}{name};
$vars{GIT_AUTHOR_EMAIL} = $users->{$user}{email};
}
}
if ( $ENV{GIT_AUTHOR_EMAIL} =~ /(.*)\@dev\.catalystframework\.org$/ ) {
if ( my $u = $users->{$1} ) {
$vars{GIT_AUTHOR_NAME} ||= $u->{name};
$vars{GIT_AUTHOR_EMAIL} ||= $u->{email};
}
}
if ( $ENV{GIT_COMMITTER_EMAIL} =~ /(.*)\@dev\.catalystframework\.org$/ ) {
if ( my $u = $users->{$1} ) {
$vars{GIT_COMMITTER_NAME} ||= $u->{name};
$vars{GIT_COMMITTER_EMAIL} ||= $u->{email};
}
}
for my $key ( keys %vars ) {
print "export $key='$vars{$key}';\n";
}