From 99c1705130958bbdb15dc623eb1209106c125cd3 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Date: Tue, 11 Nov 2014 14:18:40 +0100
Subject: [PATCH] add a way to do instance-specific configuration

Change-Id: I6862970b6bb5ebb6a171c40a5ed4668d49778b28
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
---
 git-hooks/sanitize-commit | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/git-hooks/sanitize-commit b/git-hooks/sanitize-commit
index 8ea2f74..6ec4c76 100755
--- a/git-hooks/sanitize-commit
+++ b/git-hooks/sanitize-commit
@@ -11,14 +11,15 @@ use strict;
 use warnings;
 use Cwd;
 
-if ($#ARGV < 0 or $#ARGV > 1 || ($#ARGV == 1 && $ARGV[1] !~ /^(strict|gerrit(-rest)?)$/)) {
-    print STDERR "Usage: $0 <sha1> [strict]\n";
+if ($#ARGV < 0 or $#ARGV > 2 or ($#ARGV >= 1 && $ARGV[1] !~ /^(easy|strict|gerrit(-rest)?)$/)) {
+    print STDERR "Usage: $0 <sha1> [{easy|strict|gerrit|gerrit-rest} [instance]]\n";
     exit 2;
 }
 my $sha1 = $ARGV[0];
-my $gerrit_rest = ($#ARGV == 1 && $ARGV[1] eq "gerrit-rest");
-my $gerrit = $gerrit_rest || ($#ARGV == 1 && $ARGV[1] eq "gerrit");
-my $strict = $gerrit || ($#ARGV == 1 && $ARGV[1] eq "strict");
+my $gerrit_rest = ($#ARGV >= 1 && $ARGV[1] eq "gerrit-rest");
+my $gerrit = $gerrit_rest || ($#ARGV >= 1 && $ARGV[1] eq "gerrit");
+my $strict = $gerrit || ($#ARGV >= 1 && $ARGV[1] eq "strict");
+my $instance = ($#ARGV == 2) ? $ARGV[2] : "default";
 
 my $repo = getcwd();
 $repo =~ s,/?\.git$,,;
@@ -27,6 +28,8 @@ my %config = ();
 for (`git config --list`) {
     if (/^sanity\.\Q$repo\E\.([^=]+)=(.*$)/) {
         $config{$1} = $2;
+    } elsif (/^sanity\.\Q$instance\E\.([^=]+)=(.*$)/) {
+        $config{$1} = $2;
     }
 }
 
-- 
GitLab