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

Stephan Bergmann sbergman at redhat.com
Thu Nov 16 08:54:10 UTC 2017


 .git-hooks/pre-commit |   58 ++++++++++++++++++++++++++------------------------
 1 file changed, 31 insertions(+), 27 deletions(-)

New commits:
commit c74f6d3c64b943e26d5af1850bb55780b60602d6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Nov 16 09:53:33 2017 +0100

    Warn when commit touches new files, but no suitable clang-format is found
    
    Change-Id: Ifd254c30b8aecf6e7aec00bbfc8522a91bfa0909

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index 5c7c14b8d4a7..80f2e0b4c591 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -148,33 +148,30 @@ sub check_style($)
         }
     }
 
-    # Check if clang-format is installed.
-    if (! -x $clang_format)
-    {
-        # As a first step, don't do any checks in this case.
-        return;
-
-        my $platform = "linux64";
-        my $download = "wget";
-        if ($^O eq "cygwin")
-        {
-            $platform = "win.exe";
-        }
-        elsif ($^O eq "darwin")
-        {
-            $platform = "mac";
-            $download = "curl -O";
-        }
-
-        print("Error: clang-format is not found in $opt_lo or in your PATH.\n");
-        print("To get a clang-format binary for your platform, please do:\n\n");
-        print("mkdir -p $opt_lo\n");
-        print("cd $opt_lo\n");
-        print("$download https://dev-www.libreoffice.org/bin/clang-format-$version-$platform\n");
-        print("cp clang-format-$version-$platform clang-format\n");
-        print("chmod +x clang-format\n");
-        exit(1);
-    }
+#   # Check if clang-format is installed.
+#   if (! -x $clang_format)
+#   {
+#       my $platform = "linux64";
+#       my $download = "wget";
+#       if ($^O eq "cygwin")
+#       {
+#           $platform = "win.exe";
+#       }
+#       elsif ($^O eq "darwin")
+#       {
+#           $platform = "mac";
+#           $download = "curl -O";
+#       }
+#
+#       print("Error: clang-format is not found in $opt_lo or in your PATH.\n");
+#       print("To get a clang-format binary for your platform, please do:\n\n");
+#       print("mkdir -p $opt_lo\n");
+#       print("cd $opt_lo\n");
+#       print("$download https://dev-www.libreoffice.org/bin/clang-format-$version-$platform\n");
+#       print("cp clang-format-$version-$platform clang-format\n");
+#       print("chmod +x clang-format\n");
+#       exit(1);
+#   }
 
     # Read the blacklist.
     if (open(LINES, "solenv/clang-format/blacklist"))
@@ -199,6 +196,13 @@ sub check_style($)
         chomp $filename;
         if ($filename =~ /\.($src)$/ and !exists($blacklist_names{$filename}))
         {
+            if (! -x $clang_format)
+            {
+                print("\nWARNING: Commit touches new (non-blacklisted) files, but no clang-format"
+                      . " ${version}\n");
+                print(" found (via CLANG_FORMAT or PATH env vars, or in ${opt_lo}).\n\n");
+                return;
+            }
             if (system("$clang_format $filename | git --no-pager diff --no-index --exit-code $filename -") != 0)
             {
                 push @bad_names, $filename;


More information about the Libreoffice-commits mailing list