summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-05-07 15:12:51 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2012-05-09 12:06:06 +0200
commit32c5f1b38162992ac97918c18382767b91e1b78b (patch)
treef698fd431be21197af28f908ea82dad8a3ef2ae4
parent48fc5b632a679c015bdb7bbc042d3f61a9519554 (diff)
add possibility of persistent configuration
options are stored in as git options in the group sanity.<dirname>, with <dirname> being the basename of the repository. it is recommended that these keys are added to the global git config, outside the clones of the inspected repos. the only currently recognized option is "flags", which corresponds to the GIT_PUSH environment variable. Change-Id: I011d4f335ca94b5aa08fc9bcb6283e6c2f7b3b79 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
-rwxr-xr-xgit-hooks/sanitize-commit16
1 files changed, 16 insertions, 0 deletions
diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit
index 1d5c8f1..3c85f7d 100755
--- a/git-hooks/sanitize-commit
+++ b/git-hooks/sanitize-commit
@@ -7,6 +7,7 @@
#
use strict;
+use Cwd;
if ($#ARGV < 0 or $#ARGV > 1 || ($#ARGV == 1 && $ARGV[1] !~ /^(strict|gerrit)$/)) {
print STDERR "Usage: $0 <sha1> [strict]\n";
@@ -16,12 +17,27 @@ my $sha1 = $ARGV[0];
my $gerrit = ($#ARGV == 1 && $ARGV[1] eq "gerrit");
my $strict = $gerrit || ($#ARGV == 1 && $ARGV[1] eq "strict");
+my $repo = getcwd();
+$repo =~ s,/?\.git$,,;
+$repo =~ s,^.*/,,;
+my %config = ();
+for (`git config --list`) {
+ if (/^sanity\.\Q$repo\E\.([^=]+)=(.*$)/) {
+ $config{$1} = $2;
+ }
+}
+
my %cfg = ();
if (defined $ENV{GIT_PUSH}) {
foreach my $c (split ",", $ENV{GIT_PUSH}) {
$cfg{$c} = 1;
}
}
+if (defined $config{flags}) {
+ foreach my $c (split ",", $config{flags}) {
+ $cfg{$c} = 1;
+ }
+}
my $fail = 0;
my $printed = $gerrit;
my $file = "";