Add dev tooling to use precious
This commit is contained in:
15
git/hooks/pre-commit.sh
Executable file
15
git/hooks/pre-commit.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
status=0
|
||||
|
||||
PRECIOUS=$(which precious)
|
||||
if [[ -z $PRECIOUS ]]; then
|
||||
PRECIOUS=./bin/precious
|
||||
fi
|
||||
|
||||
"$PRECIOUS" lint -s
|
||||
if (( $? != 0 )); then
|
||||
status+=1
|
||||
fi
|
||||
|
||||
exit $status
|
||||
26
git/setup.pl
Executable file
26
git/setup.pl
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Cwd qw( abs_path );
|
||||
|
||||
symlink_hook('pre-commit');
|
||||
|
||||
sub symlink_hook {
|
||||
my $hook = shift;
|
||||
|
||||
my $dot = ".git/hooks/$hook";
|
||||
my $file = "git/hooks/$hook.sh";
|
||||
my $link = "../../$file";
|
||||
|
||||
if ( -e $dot ) {
|
||||
if ( -l $dot ) {
|
||||
return if readlink $dot eq $link;
|
||||
}
|
||||
warn "You already have a hook at $dot!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
symlink $link, $dot;
|
||||
}
|
||||
Reference in New Issue
Block a user