diff options
author | David Bradford <david.bradford@mongodb.com> | 2020-08-24 19:04:28 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-26 15:58:35 +0000 |
commit | ac966012c5f16925226d0d42b43bd6ab92c7f59d (patch) | |
tree | 1b6b0854735592eb7266f190e0f9fc850a4c68c7 /buildscripts/linter | |
parent | a3a33f7d40147f50442292df215063fb36f6f70b (diff) | |
download | mongo-ac966012c5f16925226d0d42b43bd6ab92c7f59d.tar.gz |
SERVER-50401: Use evergreen manifest to determine revisions to compare against
Diffstat (limited to 'buildscripts/linter')
-rw-r--r-- | buildscripts/linter/filediff.py | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/buildscripts/linter/filediff.py b/buildscripts/linter/filediff.py index de84691d1a3..7dbad6d9d58 100644 --- a/buildscripts/linter/filediff.py +++ b/buildscripts/linter/filediff.py @@ -12,29 +12,25 @@ if __name__ == "__main__" and __package__ is None: # pylint: disable=wrong-import-position from buildscripts.linter import git -from buildscripts.patch_builds.change_data import find_changed_files_in_repos +from buildscripts.patch_builds.change_data import generate_revision_map, \ + RevisionMap, find_changed_files_in_repos + # pylint: enable=wrong-import-position LOGGER = structlog.get_logger(__name__) +MONGO_REVISION_ENV_VAR = "REVISION" +ENTERPRISE_REVISION_ENV_VAR = "ENTERPRISE_REV" -def _get_revision_for_repo(path: str) -> str: - """ - Get the git revision for the given git repository. - - :param path: Path to git repository. - :return: Git revision to compare against for given repo. - """ - if "enterprise" in path: - return os.environ.get("ENTERPRISE_REV") - return os.environ.get("REVISION") - - -def _get_repos_and_revisions() -> Tuple[List[Repo], Dict[str, str]]: +def _get_repos_and_revisions() -> Tuple[List[Repo], RevisionMap]: """Get the repo object and a map of revisions to compare against.""" modules = git.get_module_paths() repos = [Repo(path) for path in modules] - revision_map = {repo.git_dir: _get_revision_for_repo(repo.git_dir) for repo in repos} + revision_map = generate_revision_map( + repos, { + "mongo": os.environ.get(MONGO_REVISION_ENV_VAR), + "enterprise": os.environ.get(ENTERPRISE_REVISION_ENV_VAR) + }) return repos, revision_map @@ -49,7 +45,7 @@ def _filter_file(filename: str, is_interesting_file: Callable) -> bool: return os.path.exists(filename) and is_interesting_file(filename) -def gather_changed_files_for_lint(is_interesting_file: Callable): +def gather_changed_files_for_lint(is_interesting_file: Callable) -> List[str]: """ Get the files that have changes since the last git commit. @@ -65,5 +61,4 @@ def gather_changed_files_for_lint(is_interesting_file: Callable): ] LOGGER.info("Found files to lint", files=files) - return files |