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
history.

BUG=none
TEST=submit a series of CLS that modifies and then renames an ebuild
CQ-DEPEND=I52e8b4a501b47aa57b17f0457136d7be62913af6

Change-Id: I8e673e6cef8f8ff96de1f5f0fa1f1824c48e27d8
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/327687
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index b406f95..969d828 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -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 @@
       continue
 
     try:
-      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])