Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 48 lines (40 sloc) 1.338 kb
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 39 40 41 42 43 44 45 46 47
#!/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";
}

Something went wrong with that request. Please try again.