diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-11-16 09:53:33 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-11-16 09:53:33 +0100 |
commit | c74f6d3c64b943e26d5af1850bb55780b60602d6 (patch) | |
tree | 09ce7b98710dba77ca604b182687b8962a2ab195 /.git-hooks | |
parent | 121303615054568c204def97872343d2014af4a0 (diff) |
Warn when commit touches new files, but no suitable clang-format is found
Change-Id: Ifd254c30b8aecf6e7aec00bbfc8522a91bfa0909
Diffstat (limited to '.git-hooks')
-rwxr-xr-x | .git-hooks/pre-commit | 58 |
1 files changed, 31 insertions, 27 deletions
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; |