Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 610fa96

Browse filesBrowse files
bnoordhuisrvagg
authored andcommitted
cpplint: make it possible to run outside git repo
cpplint uses the top-level .git directory to determine what the root is for #include guards. If it doesn't find a .git directory, it walks up all the way to the system root and subsequently complains that guards must be written as HOME_USER_SRC_NODE_SRC_FILENAME_H_. This commit replaces the .git-based path munging with a fixed root path relative to the location of the cpplint script, making it possible to successfully run `make test` from an extracted tarball. Fixes: #2693 PR-URL: #2710 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 118f48c commit 610fa96
Copy full SHA for 610fa96

File tree

Expand file treeCollapse file tree

1 file changed

+4
-31
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-31
lines changed
Open diff view settings
Collapse file

‎tools/cpplint.py‎

Copy file name to clipboardExpand all lines: tools/cpplint.py
+4-31Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -695,37 +695,10 @@ def RepositoryName(self):
695695
locations won't see bogus errors.
696696
"""
697697
fullname = self.FullName()
698-
699-
if os.path.exists(fullname):
700-
project_dir = os.path.dirname(fullname)
701-
702-
if os.path.exists(os.path.join(project_dir, ".svn")):
703-
# If there's a .svn file in the current directory, we recursively look
704-
# up the directory tree for the top of the SVN checkout
705-
root_dir = project_dir
706-
one_up_dir = os.path.dirname(root_dir)
707-
while os.path.exists(os.path.join(one_up_dir, ".svn")):
708-
root_dir = os.path.dirname(root_dir)
709-
one_up_dir = os.path.dirname(one_up_dir)
710-
711-
prefix = os.path.commonprefix([root_dir, project_dir])
712-
return fullname[len(prefix) + 1:]
713-
714-
# Not SVN? Try to find a git or hg top level directory by searching up
715-
# from the current path.
716-
root_dir = os.path.dirname(fullname)
717-
while (root_dir != os.path.dirname(root_dir) and
718-
not os.path.exists(os.path.join(root_dir, ".git")) and
719-
not os.path.exists(os.path.join(root_dir, ".hg"))):
720-
root_dir = os.path.dirname(root_dir)
721-
722-
if (os.path.exists(os.path.join(root_dir, ".git")) or
723-
os.path.exists(os.path.join(root_dir, ".hg"))):
724-
prefix = os.path.commonprefix([root_dir, project_dir])
725-
return fullname[len(prefix) + 1:]
726-
727-
# Don't know what to do; header guard warnings may be wrong...
728-
return fullname
698+
# XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory.
699+
toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
700+
prefix = os.path.commonprefix([fullname, toplevel])
701+
return fullname[len(prefix) + 1:]
729702

730703
def Split(self):
731704
"""Splits the file into the directory, basename, and extension.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.