Skip to content

Instantly share code, notes, and snippets.

@dolmen
Created April 8, 2014 10:32
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 dolmen/10108006 to your computer and use it in GitHub Desktop.
Save dolmen/10108006 to your computer and use it in GitHub Desktop.
My git post-checkout hook
#!/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