* [gentoo-commits] proj/portage:master commit in: repoman/cnf/linechecks/, repoman/lib/repoman/modules/linechecks/gentoo_header/
@ 2018-09-19 17:19 Michał Górny
0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2018-09-19 17:19 UTC (permalink / raw
To: gentoo-commits
commit: c4096aff486da02fb2ddd410f934fe9e418741ba
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 18 08:49:55 2018 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 19 17:18:22 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=c4096aff
repoman: Update header checks for the new copyright policy
Update the header checks to account for the new copyright policy:
- there can be multiple copyright lines,
- copyright owner can be anyone,
- at least one copyright line should match last modification date.
This requires updating the check to appropriately allow the license
line to move down. Additionally, the copyright date error is separated
from invalid copyright line error.
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
repoman/cnf/linechecks/linechecks.yaml | 3 +-
| 47 ++++++++++++++--------
2 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml
index 634381e80..32b1bf82f 100644
--- a/repoman/cnf/linechecks/linechecks.yaml
+++ b/repoman/cnf/linechecks/linechecks.yaml
@@ -9,7 +9,8 @@ repoman_version: 2.3.3
# configuration file for the LineCheck plugins run via the multicheck
# scan module
errors:
- COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d'
+ COPYRIGHT_ERROR: 'Invalid Copyright on line: %d'
+ COPYRIGHT_DATE_ERROR: 'No copyright for last modification date before line %d'
LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
ID_HEADER_ERROR: 'Stale CVS header on line: %d'
NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'
--git a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
index 4b75fc4b5..c64674319 100644
--- a/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
+++ b/repoman/lib/repoman/modules/linechecks/gentoo_header/header.py
@@ -17,33 +17,46 @@ class EbuildHeader(LineCheck):
repoman_check_name = 'ebuild.badheader'
- gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$'
+ copyright_re = re.compile(r'^# Copyright ((1999|2\d\d\d)-)?(?P<year>2\d\d\d) \w')
gentoo_license = (
'# Distributed under the terms'
' of the GNU General Public License v2')
id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*')
- blank_line_re = re.compile(r'^$')
ignore_comment = False
def new(self, pkg):
if pkg.mtime is None:
- self.modification_year = r'2\d\d\d'
+ self.modification_year = None
else:
- self.modification_year = str(time.gmtime(pkg.mtime)[0])
- self.gentoo_copyright_re = re.compile(
- self.gentoo_copyright % self.modification_year)
+ self.modification_year = time.gmtime(pkg.mtime)[0]
+ self.last_copyright_line = -1
+ self.last_copyright_year = -1
def check(self, num, line):
- if num > 2:
+ if num > self.last_copyright_line + 2:
return
- elif num == 0:
- if not self.gentoo_copyright_re.match(line):
+ elif num == self.last_copyright_line + 1:
+ # copyright can extend for a few initial lines
+ copy_match = self.copyright_re.match(line)
+ if copy_match is not None:
+ self.last_copyright_line = num
+ self.last_copyright_year = max(self.last_copyright_year,
+ int(copy_match.group('year')))
+ # no copyright lines found?
+ elif self.last_copyright_line == -1:
return self.errors['COPYRIGHT_ERROR']
- elif num == 1 and line.rstrip('\n') != self.gentoo_license:
- return self.errors['LICENSE_ERROR']
- elif num == 2 and self.id_header_re.match(line):
- return self.errors['ID_HEADER_ERROR']
- elif num == 2 and not self.blank_line_re.match(line):
- return self.errors['NO_BLANK_LINE_ERROR']
-
-
+ else:
+ # verify that the newest copyright line found
+ # matches the year of last modification
+ if (self.modification_year is not None
+ and self.last_copyright_year != self.modification_year):
+ return self.errors['COPYRIGHT_DATE_ERROR']
+
+ # copyright is immediately followed by license
+ if line.rstrip('\n') != self.gentoo_license:
+ return self.errors['LICENSE_ERROR']
+ elif num == self.last_copyright_line + 2:
+ if self.id_header_re.match(line):
+ return self.errors['ID_HEADER_ERROR']
+ elif line.rstrip('\n') != '':
+ return self.errors['NO_BLANK_LINE_ERROR']
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-19 17:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-19 17:19 [gentoo-commits] proj/portage:master commit in: repoman/cnf/linechecks/, repoman/lib/repoman/modules/linechecks/gentoo_header/ Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox