Skip to content

Commit

Permalink
cpplint: Fix --root for non-subdirectories
Browse files Browse the repository at this point in the history
Using cpplint.py --root with directories at a more outer level
than the repository would not work.

For example given

  /a/b/c/.git/filename.cpp

Trying to use --root=/a/b would get ignored, and it would
ask for a headerguard of FILENAME_H_ instead of C_FILENAME_H_
as expected.

Now --root will always use the "full name" and then strip off --root
prefix, giving us the desired effect.
  • Loading branch information
iam committed Nov 6, 2017
1 parent ec88ff9 commit a38fcbb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cpplint/cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,8 @@ def GetHeaderGuardCPPVariable(filename):
fileinfo = FileInfo(filename)
file_path_from_root = fileinfo.RepositoryName()
if _root:
file_path_from_root = fileinfo.FullName()

suffix = os.sep
# On Windows using directory separator will leave us with
# "bogus escape error" unless we properly escape regex.
Expand Down

0 comments on commit a38fcbb

Please sign in to comment.