Skip to content

Instantly share code, notes, and snippets.

@wayne530
Created April 27, 2011 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wayne530/943653 to your computer and use it in GitHub Desktop.
Save wayne530/943653 to your computer and use it in GitHub Desktop.
git binary wrapper for author name/email normalization
#!/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