Created
April 27, 2011 03:17
-
-
Save wayne530/943653 to your computer and use it in GitHub Desktop.
git binary wrapper for author name/email normalization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
my $default_email = 'svn@mycompany.com'; | |
my $default_name = 'My Company SVN'; | |
my $cmd = "/usr/bin/git \"" . join('" "', @ARGV) . "\""; | |
local *PIPE; | |
open(PIPE, "$cmd |"); | |
while(<PIPE>) { | |
if (/^([AERF]):(.+)/) { | |
my $prefix = $1; | |
my $value = $2; | |
if ($value =~ /userA/i) { | |
$value = $prefix eq 'E' || $prefix eq 'F' ? 'usera@mycompany.com' : 'User A'; | |
} elsif ($value =~ /(?:userB|deploy|eng)/i) { | |
$value = $prefix eq 'E' || $prefix eq 'F' ? 'userb@mycompany.com' : 'User B'; | |
} else { | |
$value = $prefix eq 'E' || $prefix eq 'F' ? $default_email : $default_name; | |
} | |
print join(":", $prefix, $value), "\n"; | |
} else { | |
print; | |
} | |
} | |
close(PIPE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment