diff options
author | David Bradford <david.bradford@mongodb.com> | 2020-05-07 13:48:34 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-07 18:25:41 +0000 |
commit | 2a13ecc1e5b83ddb645056358f8ca8d84af7c0c5 (patch) | |
tree | 062b11a1de8f649e662960b31c59d8c732e55f42 /buildscripts/linter | |
parent | 7262763330522b4e3323558cc2f5af0651563768 (diff) | |
download | mongo-2a13ecc1e5b83ddb645056358f8ca8d84af7c0c5.tar.gz |
SERVER-48017: Filter out deleted files from files to lint
Diffstat (limited to 'buildscripts/linter')
-rw-r--r-- | buildscripts/linter/filediff.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/buildscripts/linter/filediff.py b/buildscripts/linter/filediff.py index 222e33df932..de84691d1a3 100644 --- a/buildscripts/linter/filediff.py +++ b/buildscripts/linter/filediff.py @@ -38,6 +38,17 @@ def _get_repos_and_revisions() -> Tuple[List[Repo], Dict[str, str]]: return repos, revision_map +def _filter_file(filename: str, is_interesting_file: Callable) -> bool: + """ + Determine if file should be included based on existence and passed in method. + + :param filename: Filename to check. + :param is_interesting_file: Function to determine if file is interesting. + :return: True if file exists and is interesting. + """ + return os.path.exists(filename) and is_interesting_file(filename) + + def gather_changed_files_for_lint(is_interesting_file: Callable): """ Get the files that have changes since the last git commit. @@ -49,7 +60,9 @@ def gather_changed_files_for_lint(is_interesting_file: Callable): LOGGER.info("revisions", revision=revision_map) candidate_files = find_changed_files_in_repos(repos, revision_map) - files = [filename for filename in candidate_files if is_interesting_file(filename)] + files = [ + filename for filename in candidate_files if _filter_file(filename, is_interesting_file) + ] LOGGER.info("Found files to lint", files=files) |