@@ -453,6 +453,31 @@ class HeaderAddChecker(CommitChecker):
return issues
+class LicenseChecker(CommitChecker):
+ commit_types = (Commit, StagedChanges, Amendment)
+ dependencies = ('reuse',)
+
+ missing_license_regex = re.compile(r'^(.*): no license identifier$')
+
+ @classmethod
+ def check(cls, commit, top_level):
+ issues = []
+
+ ret = subprocess.run(['reuse', 'lint-file'] + commit.files('AR'),
+ stdout=subprocess.PIPE)
+
+ for line in ret.stdout.decode('utf-8').splitlines():
+ match = LicenseChecker.missing_license_regex.match(line)
+ if not match:
+ continue
+
+ filename = match.group(1)
+ issue = CommitIssue(f'File {filename} has no license identifier')
+ issues.append(issue)
+
+ return issues
+
+
class TitleChecker(CommitChecker):
commit_types = (Commit,)
Add a checker, based on the reuse tool, to detect files without a valid license. The tool is optional, the checker will be skipped when not available. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- I figured out that if we want this in CI, we should have it in checkstyle too. In which case we could drop the license job from CI. --- utils/checkstyle.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) base-commit: 4b6c47bd6675c428c19ea76370f0301c24f23bf1