[Libreoffice-commits] core.git: .git-hooks/pre-commit

Stephan Bergmann sbergman at redhat.com
Mon Nov 13 10:59:54 UTC 2017


 .git-hooks/pre-commit |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit e61a1b8dd8d4ea99f50eed3f8118bc01a0617889
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Nov 13 11:59:08 2017 +0100

    First look for clang-format in CLANG_FORMT env var
    
    Change-Id: I5de5c6f3e8be1d40c03cbddb9d2f4414b9a5791b

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index 3743f6b79d6c..5c7c14b8d4a7 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -127,19 +127,23 @@ sub check_style($)
     my @bad_names = ();
     my %blacklist_names = ();
 
-    # Use clang-format from PATH, unless it's available in our dedicated
+    # Use clang-format from CLANG_FORMAT, or from PATH unless it's available in our dedicated
     # directory.
-    my $opt_lo = "/opt/lo/bin";
-    my $clang_format = "$opt_lo/clang-format";
     my $version = "5.0.0";
-    if (!is_matching_clang_format_version($clang_format, $version))
+    my $opt_lo = "/opt/lo/bin";
+    my $clang_format = $ENV{CLANG_FORMAT};
+    if (!(defined($clang_format) && is_matching_clang_format_version($clang_format, $version)))
     {
-        foreach my $dir (split /:/, $ENV{PATH})
+        $clang_format = "$opt_lo/clang-format";
+        if (!is_matching_clang_format_version($clang_format, $version))
         {
-            $clang_format = "$dir/clang-format";
-            if (is_matching_clang_format_version($clang_format, $version))
+            foreach my $dir (split /:/, $ENV{PATH})
             {
-                last;
+                $clang_format = "$dir/clang-format";
+                if (is_matching_clang_format_version($clang_format, $version))
+                {
+                    last;
+                }
             }
         }
     }


More information about the Libreoffice-commits mailing list