summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-02-24 17:13:10 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-02-24 17:13:10 -0700
commit3eddb2f9db1d7c90928ba4acb8cb269f1a350c09 (patch)
tree4ee82a4828be6a07b03dd6fefe860745ac43f16f /bin
parent89c16802fe2b76d5261941860aad160ff4fcd911 (diff)
downloaddotfiles-3eddb2f9db1d7c90928ba4acb8cb269f1a350c09.tar.gz
make it possible to run install-git-hooks without going via mr
Useful in the repos of new projects.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/install-git-hooks5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/install-git-hooks b/bin/install-git-hooks
index 34db09b2..ea070e7d 100755
--- a/bin/install-git-hooks
+++ b/bin/install-git-hooks
@@ -18,11 +18,12 @@
use strict;
use warnings;
+use Cwd qw(getcwd);
use List::Util qw(uniq);
use File::Spec::Functions qw(catfile);
die "usage: install-git-hooks NAME\n" unless @ARGV == 1;
-die "must be run by mr(1)\n" unless $ENV{MR_REPO};
+my $target = $ENV{MR_REPO} || getcwd;
my $source = catfile $ENV{HOME}, qw(src dotfiles hooks git), $ARGV[0];
my $chained_hook = catfile $ENV{HOME}, qw(src dotfiles hooks git chained_hook);
@@ -31,7 +32,7 @@ opendir(my $dirh, $source) or die "could not find $source dir\n";
my @hooks = grep { $_ ne '.' and $_ ne '..' } readdir $dirh;
my @hook_types = uniq map { /^([^_]+)_/; $1 // () } @hooks;
-chdir $ENV{MR_REPO};
+chdir $target;
my $config_hooks_path = `git config core.hooksPath`;
chomp(my $hook_dir = $config_hooks_path || `git rev-parse --git-path hooks`);