Provides clarification that LICENSE is in repo 97/36197/1
authorlhinds <lhinds@redhat.com>
Mon, 19 Jun 2017 15:41:40 +0000 (16:41 +0100)
committerlhinds <lhinds@redhat.com>
Mon, 19 Jun 2017 15:41:40 +0000 (16:41 +0100)
This change peforms a clarification that a LICENSE file exists
within the root folder of the set project repo.

This feature is only for complete project scans and not a patch
scan.

JIRA:RELENG-235

Change-Id: I6d238158f7501aaff6c21ecc59b505b5c79565f2
Signed-off-by: lhinds <lhinds@redhat.com>
anteater/src/project_scan.py

index 9b143e9..09a4791 100644 (file)
@@ -57,6 +57,7 @@ def prepare_project(project, project_dir):
 
     # Perform licence header checks
     licence_check(licence_ext, licence_ignore, project, project_dir)
+    licence_root_check(project_dir, project)
 
 
 def scan_file(project_dir, project, binary_list, binary_project_list,
@@ -124,6 +125,20 @@ def scan_file(project_dir, project, binary_list, binary_project_list,
                                           format(full_path))
 
 
+def licence_root_check(project_dir, project):
+    if os.path.isfile(project_dir + '/LICENSE'):
+        logger.info('LICENSE file present in: {0}'.
+                    format(project_dir))
+    else:
+        logger.error('LICENSE file missing in: {0}'.
+                     format(project_dir))
+        with open(reports_dir + "licence-" + project + ".log",
+                  "a") \
+                as gate_report:
+            gate_report.write('LICENSE file missing in: {0}\n'.
+                              format(project_dir))
+
+
 def licence_check(licence_ext, licence_ignore, project, project_dir):
     """ Peform basic checks for the presence of licence strings """
     for root, dirs, files in os.walk(project_dir):