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 4a2bd2d

Browse filesBrowse files
bnoordhuisMyles Borins
authored andcommitted
tools: allow cpplint to run outside git repo
This reapplies commit a493dab ("cpplint: make it possible to run outside git repo") from September 2015, this time with a proper status line. PR-URL: #7462 Refs: #2693 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
1 parent 09e98a4 commit 4a2bd2d
Copy full SHA for 4a2bd2d

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎tools/cpplint.py‎

Copy file name to clipboardExpand all lines: tools/cpplint.py
+4-34Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,40 +1073,10 @@ def RepositoryName(self):
10731073
locations won't see bogus errors.
10741074
"""
10751075
fullname = self.FullName()
1076-
1077-
if os.path.exists(fullname):
1078-
project_dir = os.path.dirname(fullname)
1079-
1080-
if os.path.exists(os.path.join(project_dir, ".svn")):
1081-
# If there's a .svn file in the current directory, we recursively look
1082-
# up the directory tree for the top of the SVN checkout
1083-
root_dir = project_dir
1084-
one_up_dir = os.path.dirname(root_dir)
1085-
while os.path.exists(os.path.join(one_up_dir, ".svn")):
1086-
root_dir = os.path.dirname(root_dir)
1087-
one_up_dir = os.path.dirname(one_up_dir)
1088-
1089-
prefix = os.path.commonprefix([root_dir, project_dir])
1090-
return fullname[len(prefix) + 1:]
1091-
1092-
# Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
1093-
# searching up from the current path.
1094-
root_dir = current_dir = os.path.dirname(fullname)
1095-
while current_dir != os.path.dirname(current_dir):
1096-
if (os.path.exists(os.path.join(current_dir, ".git")) or
1097-
os.path.exists(os.path.join(current_dir, ".hg")) or
1098-
os.path.exists(os.path.join(current_dir, ".svn"))):
1099-
root_dir = current_dir
1100-
current_dir = os.path.dirname(current_dir)
1101-
1102-
if (os.path.exists(os.path.join(root_dir, ".git")) or
1103-
os.path.exists(os.path.join(root_dir, ".hg")) or
1104-
os.path.exists(os.path.join(root_dir, ".svn"))):
1105-
prefix = os.path.commonprefix([root_dir, project_dir])
1106-
return fullname[len(prefix) + 1:]
1107-
1108-
# Don't know what to do; header guard warnings may be wrong...
1109-
return fullname
1076+
# XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory.
1077+
toplevel = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
1078+
prefix = os.path.commonprefix([fullname, toplevel])
1079+
return fullname[len(prefix) + 1:]
11101080

11111081
def Split(self):
11121082
"""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.