tweak keywords checking logic

Just backend improvements:
 - use more standardized func name
 - use _filter_files rather than ad-hoc implementation

BUG=chromium:340036
TEST=`./pre-upload_unittest.py` passes

Change-Id: Ia76364fbf1a7dc1d42e19554126d1ae61193feba
Reviewed-on: https://chromium-review.googlesource.com/184624
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/pre-upload.py b/pre-upload.py
index 6f38310..dea41bc 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -548,7 +548,7 @@
         ('\n\t'.join(['%s: EAPI=%s' % x for x in bad_ebuilds]), url))
 
 
-def _check_keywords(_project, commit):
+def _check_ebuild_keywords(_project, commit):
   """Make sure we use the new style KEYWORDS when possible in ebuilds.
 
   If an ebuild generally does not care about the arch it is running on, then
@@ -568,7 +568,10 @@
 
   get_keywords = re.compile(r'^\s*KEYWORDS="(.*)"')
 
-  ebuilds = [x for x in _get_affected_files(commit) if x.endswith('.ebuild')]
+  ebuilds_re = [r'\.ebuild$']
+  ebuilds = _filter_files(_get_affected_files(commit, relative=True),
+                          ebuilds_re)
+
   for ebuild in ebuilds:
     for _, line in _get_file_diff(ebuild, commit):
       m = get_keywords.match(line)
@@ -836,6 +839,7 @@
     _check_change_has_test_field,
     _check_change_has_proper_changeid,
     _check_ebuild_eapi,
+    _check_ebuild_keywords,
     _check_ebuild_licenses,
     _check_ebuild_virtual_pv,
     _check_no_stray_whitespace,
@@ -843,7 +847,6 @@
     _check_license,
     _check_no_tabs,
     _check_for_uprev,
-    _check_keywords,
 ]