diff options
author | David Bradford <david.bradford@mongodb.com> | 2020-03-19 17:08:11 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-20 17:56:48 +0000 |
commit | ef6cd28bc3f39d2c7e7bb175fcbc7e83584f11c0 (patch) | |
tree | 95cfb0dba0f89c09687eaf40dd2e31df1a5137b9 /buildscripts/eslint.py | |
parent | 40ecb806e22bb82df5e5ed74c11f7da46bf1136c (diff) | |
download | mongo-ef6cd28bc3f39d2c7e7bb175fcbc7e83584f11c0.tar.gz |
SERVER-47004: Properly run eslint on modules
Diffstat (limited to 'buildscripts/eslint.py')
-rwxr-xr-x | buildscripts/eslint.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/buildscripts/eslint.py b/buildscripts/eslint.py index 2a3eba272ff..220385a1e91 100755 --- a/buildscripts/eslint.py +++ b/buildscripts/eslint.py @@ -19,7 +19,7 @@ import sys import tarfile import tempfile import threading -from typing import Optional +from typing import Optional, Dict, Tuple, List import urllib.error import urllib.parse import urllib.request @@ -228,6 +228,26 @@ def lint_patch(eslint, infile): return True +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]]: + """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} + return repos, revision_map + + def lint_git_diff(eslint: Optional[str]) -> bool: """ Lint the files that have changes since the last git commit. @@ -235,8 +255,9 @@ def lint_git_diff(eslint: Optional[str]) -> bool: :param eslint: Path to eslint command. :return: True if lint was successful. """ - repos = [Repo(path) for path in git.get_module_paths()] - candidate_files = find_changed_files_in_repos(repos) + repos, revision_map = get_repos_and_revisions() + LOGGER.info("revisions", revision=revision_map) + candidate_files = find_changed_files_in_repos(repos, revision_map) LOGGER.info("Found candidate_files", candidate_files=candidate_files) files = [filename for filename in candidate_files if is_interesting_file(filename)] LOGGER.info("Found files to lint", files=files) |