Kaydet (Commit) c74f6d3c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Warn when commit touches new files, but no suitable clang-format is found

Change-Id: Ifd254c30b8aecf6e7aec00bbfc8522a91bfa0909
üst 12130361
...@@ -148,33 +148,30 @@ sub check_style($) ...@@ -148,33 +148,30 @@ sub check_style($)
} }
} }
# Check if clang-format is installed. # # Check if clang-format is installed.
if (! -x $clang_format) # if (! -x $clang_format)
{ # {
# As a first step, don't do any checks in this case. # my $platform = "linux64";
return; # my $download = "wget";
# if ($^O eq "cygwin")
my $platform = "linux64"; # {
my $download = "wget"; # $platform = "win.exe";
if ($^O eq "cygwin") # }
{ # elsif ($^O eq "darwin")
$platform = "win.exe"; # {
} # $platform = "mac";
elsif ($^O eq "darwin") # $download = "curl -O";
{ # }
$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("Error: clang-format is not found in $opt_lo or in your PATH.\n"); # print("cd $opt_lo\n");
print("To get a clang-format binary for your platform, please do:\n\n"); # print("$download https://dev-www.libreoffice.org/bin/clang-format-$version-$platform\n");
print("mkdir -p $opt_lo\n"); # print("cp clang-format-$version-$platform clang-format\n");
print("cd $opt_lo\n"); # print("chmod +x clang-format\n");
print("$download https://dev-www.libreoffice.org/bin/clang-format-$version-$platform\n"); # exit(1);
print("cp clang-format-$version-$platform clang-format\n"); # }
print("chmod +x clang-format\n");
exit(1);
}
# Read the blacklist. # Read the blacklist.
if (open(LINES, "solenv/clang-format/blacklist")) if (open(LINES, "solenv/clang-format/blacklist"))
...@@ -199,6 +196,13 @@ sub check_style($) ...@@ -199,6 +196,13 @@ sub check_style($)
chomp $filename; chomp $filename;
if ($filename =~ /\.($src)$/ and !exists($blacklist_names{$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) if (system("$clang_format $filename | git --no-pager diff --no-index --exit-code $filename -") != 0)
{ {
push @bad_names, $filename; push @bad_names, $filename;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment