diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-04-04 16:17:55 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2016-04-04 16:17:55 -0400 |
commit | 0c287324435952041423d03297248472080c8db3 (patch) | |
tree | a7d020d58ecc1afb3bad9e446633d295f154d833 /buildscripts/clang_format.py | |
parent | 462451181d36d499c6382745ca1e15eba1cd385c (diff) | |
download | mongo-0c287324435952041423d03297248472080c8db3.tar.gz |
SERVER-19986 clang_format.py lint-patch
Diffstat (limited to 'buildscripts/clang_format.py')
-rwxr-xr-x | buildscripts/clang_format.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py index 39e2de52874..186492a254a 100755 --- a/buildscripts/clang_format.py +++ b/buildscripts/clang_format.py @@ -426,13 +426,23 @@ class Repo(object): return callo(['git', '--git-dir', os.path.join(self.path, ".git"), '--work-tree', self.path] + args) - def get_candidates(self): + def _get_local_dir(self, path): + """Get a directory path relative to the git root directory + """ + if os.path.isabs(path): + return os.path.relpath(path, self.root) + return path + + def get_candidates(self, candidates): """Get the set of candidate files to check by querying the repository Returns the full path to the file for clang-format to consume. """ - # NOTE: Files may have an absolute root (i.e. leading /) - valid_files = list(self.get_candidate_files()) + if candidates is not None and len(candidates) > 0: + candidates = [self._get_local_dir(f) for f in candidates] + valid_files = list(set(candidates).intersection(self.get_candidate_files())) + else: + valid_files = list(self.get_candidate_files()) # Get the full file name here valid_files = [os.path.normpath(os.path.join(self.root, f)) for f in valid_files] |