From ea5339e31cf19b3a8f3417a10711d55b3944fbd4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 16 Nov 2017 12:08:11 +0100 Subject: 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 Reviewed-by: Miklos Vajna --- .git-hooks/pre-commit | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to '.git-hooks') 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(").\n\n"); return; } if (system("$clang_format $filename | git --no-pager diff --no-index --exit-code $filename -") != 0) -- cgit