From b63812a317046a8343ef01dae26e1653c3611f93 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 26 Feb 2016 14:15:21 -0800 Subject: [PATCH] Make default git e-mail none, force override on per-repo basis --- home/.gitconfig | 2 +- home/bin/gu | 29 +++++++++++++++++++++++++++++ home/bin/mt-git | 10 ---------- 3 files changed, 30 insertions(+), 11 deletions(-) create mode 100755 home/bin/gu delete mode 100755 home/bin/mt-git diff --git a/home/.gitconfig b/home/.gitconfig index 96fa845..f0cbd7a 100644 --- a/home/.gitconfig +++ b/home/.gitconfig @@ -1,6 +1,6 @@ [user] name = Noah Petherbridge - email = root@kirsle.net + email = "(none)" # Use `gu` to set this on a per-repo basis [alias] ci = commit diff --git a/home/bin/gu b/home/bin/gu new file mode 100755 index 0000000..dce150a --- /dev/null +++ b/home/bin/gu @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +# Set my local git e-mail on a per-repo basis to my work vs. home address. +# +# Usage: `gu work` or `gu home` (or shortcuts: `gu w` and `gu h`) + +if (scalar @ARGV == 0) { + die "Usage: gu work || gu home || gu w || gu h\n"; +} + +my $env = shift(@ARGV); +my $email = ''; + +if ($env =~ /^w/i) { + $email = 'npetherbridge@mediatemple.net'; +} +elsif ($env =~ /^h/i) { + $email = 'root@kirsle.net'; +} +else { + die "Invalid environment option, should be w[ork] or h[ome]\n"; +} + +if (!-d "./.git") { + die "You don't appear to be inside a git repository.\n"; +} + +system(qw(git config user.email), $email); +print "E-mail updated as $email for this repository.\n"; diff --git a/home/bin/mt-git b/home/bin/mt-git deleted file mode 100755 index 315c872..0000000 --- a/home/bin/mt-git +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/perl - -# Set my local git config to my work email so I don't change my global gitconfig - -if (!-d "./.git") { - die "You don't appear to be inside a git repository.\n"; -} - -system(qw(git config user.email npetherbridge@mediatemple.net)); -print "E-mail updated for this repository.\n";