summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2017-04-21 10:50:21 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2017-04-21 10:50:21 -0400
commit3e545c3e656e51dc71c04015fad15961099fd2be (patch)
treebb6ce154e06a1e9950a14f1d04a88a263b6ffee5 /buildscripts
parentb42e5752d27ff093e2fc269df85c1bf234e8dbe5 (diff)
downloadmongo-3e545c3e656e51dc71c04015fad15961099fd2be.tar.gz
SERVER-19986 clang_format.py lint-patch
(cherry picked from commit 0c287324435952041423d03297248472080c8db3)
Diffstat (limited to 'buildscripts')
-rwxr-xr-xbuildscripts/clang_format.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/buildscripts/clang_format.py b/buildscripts/clang_format.py
index f8a063624d6..bc2ba662079 100755
--- a/buildscripts/clang_format.py
+++ b/buildscripts/clang_format.py
@@ -419,13 +419,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]