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

Miklos Vajna vmiklos at collabora.co.uk
Thu Nov 16 19:25:20 UTC 2017


 .git-hooks/pre-commit |   47 ++++++++++++++++++++++-------------------------
 1 file changed, 22 insertions(+), 25 deletions(-)

New commits:
commit ea5339e31cf19b3a8f3417a10711d55b3944fbd4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 16 12:08:11 2017 +0100

    git-hooks: mention download link for clang-format when warning about it
    
    Change-Id: I99f2154bb3d15fe4a99c1d27ca20756e1fb31cec
    Reviewed-on: https://gerrit.libreoffice.org/44810
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit
index 80f2e0b4c591..298ebc4f1d9f 100755
--- a/.git-hooks/pre-commit
+++ b/.git-hooks/pre-commit
@@ -148,31 +148,6 @@ sub check_style($)
         }
     }
 
-#   # 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"))
     {
@@ -201,6 +176,28 @@ sub check_style($)
                 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");
+
+                my $platform = "linux64";
+                my $download = "wget";
+                if ($^O eq "cygwin")
+                {
+                    $platform = "win.exe";
+                }
+                elsif ($^O eq "darwin")
+                {
+                    $platform = "mac";
+                    $download = "curl -O";
+                }
+
+                print("To get a suitable binary, 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\n");
+
+                print("(Or read the instructions how to build it yourself at\n");
+                print("<https://dev-www.libreoffice.org/bin/README.clang-format.txt>).\n\n");
                 return;
             }
             if (system("$clang_format $filename | git --no-pager diff --no-index --exit-code $filename -") != 0)


More information about the Libreoffice-commits mailing list