Created
April 8, 2014 10:32
-
-
Save dolmen/10108006 to your computer and use it in GitHub Desktop.
My git post-checkout hook
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 | |
# mkdir -p ~/.gittemplate/hooks | |
# git config --global init.templatedir ~/.gittemplate | |
# | |
# Save this script as ~/.gittemplate/hooks/post-checkout | |
use 5.010; | |
use strict; | |
use warnings; | |
#say "hooks/post-checkout: start"; | |
my $origin_url = `git config remote.origin.url`; | |
chomp $origin_url; | |
# git:repo | |
# git@git:repo | |
# ssh://git@git/repo | |
my $host_regex = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; | |
exit unless $origin_url =~ m{^(?:$host_regex:|ssh://$host_regex/)[a-zA-Z0-9]}; | |
my $user_email = `git config user.email`; | |
chomp $user_email; | |
if ($user_email ne "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY") { | |
$user_email = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"; | |
# Configuration locale | |
system qw<git config user.email>, $user_email; | |
say "hooks/post-checkout: user.email switched to <$user_email>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment