licensing: don't use the current disk contents for checking ebuilds

A series of commits that both modifies and renames/deletes an ebuild
will result in a false error like this:

 * No LICENSE found in the ebuild.

because by the time the license check occurs on the "affected files",
the affected ebuild no longer exists under that name. Use
_get_affected_files() to get the contents at the correct point in

TEST=submit a series of CLS that modifies and then renames an ebuild

Change-Id: I8e673e6cef8f8ff96de1f5f0fa1f1824c48e27d8
Signed-off-by: Brian Norris <>
Reviewed-by: Mike Frysinger <>
diff --git a/ b/
index b406f95..969d828 100755
--- a/
+++ b/
@@ -769,7 +769,7 @@
 def _check_ebuild_licenses(_project, commit):
   """Check if the LICENSE field in the ebuild is correct."""
-  affected_paths = _get_affected_files(commit)
+  affected_paths = _get_affected_files(commit, relative=True)
   touched_ebuilds = [x for x in affected_paths if x.endswith('.ebuild')]
   # A list of licenses to ignore for now.
@@ -781,7 +781,8 @@
-      license_types = licenses_lib.GetLicenseTypesFromEbuild(ebuild)
+      ebuild_content = _get_file_content(ebuild, commit)
+      license_types = licenses_lib.GetLicenseTypesFromEbuild(ebuild_content)
     except ValueError as e:
       return HookFailure(e.message, [ebuild])