Commit c08c70ba authored by Jono Mingard's avatar Jono Mingard

Ignore libraries when checking code style (Bug #1486826)

Files in a directory containing a README.Mahara (or README.mahara)
file should now be ignored by the coding standards checker (and
therefore won't break "make minaccept").

behatnotneeded

Change-Id: Ibb24cb8e923117f1da6d954f4c336abdb5c0b05c
parent bb921fd8
......@@ -2,6 +2,8 @@
# This is slightly modified from Andrew Morton's Perfect Patch.
# Lines you introduce should not have trailing whitespace.
# Also check for an indentation that has SP before a TAB.
use File::Basename;
my $found_bad = 0;
my $filename;
my $reported_filename = "";
......@@ -26,11 +28,32 @@ sub bad_line {
print STDERR "$filename:$lineno:$line\n";
}
my @readme_filenames = ("README.Mahara", "README.mahara");
sub has_readme_mahara {
my $path = shift;
# Look in all parent directories in case this is part of a large library
while ($path ne ".") {
$path = dirname($path);
foreach $filename (@readme_filenames) {
if (-e "$path/$filename") {
return 1;
}
}
}
return 0;
}
my $skipfile = 0;
while (<>) {
if (m|^diff --git a/(.*) b/\1$|) {
$skipfile = has_readme_mahara($1);
$filename = $1;
next;
}
if ($skipfile) {
next;
}
if (/^@@ -\S+ \+(\d+)/) {
$lineno = $1 - 1;
next;
......@@ -92,4 +115,12 @@ while (<>) {
}
}
if ($found_bad) {
print STDERR "*\n";
print STDERR "* If you are adding a third-party library please also add a README.Mahara which includes:\n";
print STDERR "* - Version: the version of the plugin\n";
print STDERR "* - Website: the url of the website/repository to get code/updates from\n";
print STDERR "* - any changes you have made or 'none'\n";
}
exit($found_bad);
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