Duke's utils
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
885 B

#!/usr/bin/env perl
use Modern::Perl;
# The output of this should be sourced
# Ex. git filter-branch --env-filter 'source foo.sh' HEAD
print <<'PREQUEL';
#!/bin/sh
n=$GIT_AUTHOR_NAME
m=$GIT_AUTHOR_EMAIL
case ${GIT_AUTHOR_NAME} in
PREQUEL
while( my $line = <> ){
my @f = split /\s+=/, $line;
if( $f[1] =~ m/\s+(.*)\s+<([^<]+)>/) {
my ($name,$email) = ($1,$2);
# We have to by sly about quoting
if ( $name =~ /'/ ) {
say sprintf '"%s") n="%s" ; m="%s" ;;', $f[0], $name, $email;
} else {
say sprintf '"%s") n=\'%s\' ; m="%s" ;;', $f[0], $name, $email;
}
} else {
say sprintf '"%s") n="%s" ; m="%s" ;;', $f[0], $f[0], 'none@none';
}
}
print <<'AFTERWORD';
esac
export GIT_AUTHOR_NAME="$n"
export GIT_AUTHOR_EMAIL="$m"
export GIT_COMMITTER_NAME="$n"
export GIT_COMMITTER_EMAIL="$m"
AFTERWORD