diff options
author | David Bradford <david.bradford@mongodb.com> | 2020-04-29 15:25:17 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-06 13:12:44 +0000 |
commit | 74ea6aa4dfd7b3b4acf090084d36891834a49385 (patch) | |
tree | 17da63a8f40caa926e5d0e08185ba1e7f604746d /buildscripts/eslint.py | |
parent | e2ccbbd922d42fc0f68608816c9a1265c6c87409 (diff) | |
download | mongo-74ea6aa4dfd7b3b4acf090084d36891834a49385.tar.gz |
SERVER-47796: Ensure linters run against enterprise modules
Diffstat (limited to 'buildscripts/eslint.py')
-rwxr-xr-x | buildscripts/eslint.py | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/buildscripts/eslint.py b/buildscripts/eslint.py index 220385a1e91..92a90b03ff3 100755 --- a/buildscripts/eslint.py +++ b/buildscripts/eslint.py @@ -19,23 +19,23 @@ import sys import tarfile import tempfile import threading -from typing import Optional, Dict, Tuple, List +from typing import Optional import urllib.error import urllib.parse import urllib.request from distutils import spawn # pylint: disable=no-name-in-module from optparse import OptionParser -from git import Repo import structlog # Get relative imports to work when the package is not installed on the PYTHONPATH. if __name__ == "__main__" and __package__ is None: sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__))))) -from buildscripts.linter import git # pylint: disable=wrong-import-position -from buildscripts.linter import parallel # pylint: disable=wrong-import-position -from buildscripts.patch_builds.change_data import find_changed_files_in_repos # pylint: disable=wrong-import-position +# pylint: disable=wrong-import-position +from buildscripts.linter.filediff import gather_changed_files_for_lint +from buildscripts.linter import git, parallel +# pylint: enable=wrong-import-position ############################################################################## # @@ -228,26 +228,6 @@ 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. @@ -255,12 +235,7 @@ def lint_git_diff(eslint: Optional[str]) -> bool: :param eslint: Path to eslint command. :return: True if lint was successful. """ - 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) + files = gather_changed_files_for_lint(is_interesting_file) # Patch may have files that we do not want to check which is fine if files: |