MCPcopy Create free account
hub / github.com/apache/mesos / RepositoryName

Method RepositoryName

support/cpplint.py:1116–1160  ·  view source on GitHub ↗

FullName after removing the local path to the repository. If we have a real absolute path name here we can try to do something smart: detecting the root of the checkout and truncating /path/to/checkout from the name so that we get header guards that don't include things like "C:\Doc

(self)

Source from the content-addressed store, hash-verified

1114 return os.path.abspath(self._filename).replace('\\', '/')
1115
1116 def RepositoryName(self):
1117 """FullName after removing the local path to the repository.
1118
1119 If we have a real absolute path name here we can try to do something smart:
1120 detecting the root of the checkout and truncating /path/to/checkout from
1121 the name so that we get header guards that don't include things like
1122 "C:\Documents and Settings\..." or "/home/username/..." in them and thus
1123 people on different computers who have checked the source out to different
1124 locations won't see bogus errors.
1125 """
1126 fullname = self.FullName()
1127
1128 if os.path.exists(fullname):
1129 project_dir = os.path.dirname(fullname)
1130
1131 if os.path.exists(os.path.join(project_dir, ".svn")):
1132 # If there's a .svn file in the current directory, we recursively look
1133 # up the directory tree for the top of the SVN checkout
1134 root_dir = project_dir
1135 one_up_dir = os.path.dirname(root_dir)
1136 while os.path.exists(os.path.join(one_up_dir, ".svn")):
1137 root_dir = os.path.dirname(root_dir)
1138 one_up_dir = os.path.dirname(one_up_dir)
1139
1140 prefix = os.path.commonprefix([root_dir, project_dir])
1141 return fullname[len(prefix) + 1:]
1142
1143 # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
1144 # searching up from the current path.
1145 root_dir = current_dir = os.path.dirname(fullname)
1146 while current_dir != os.path.dirname(current_dir):
1147 if (os.path.exists(os.path.join(current_dir, ".git")) or
1148 os.path.exists(os.path.join(current_dir, ".hg")) or
1149 os.path.exists(os.path.join(current_dir, ".svn"))):
1150 root_dir = current_dir
1151 current_dir = os.path.dirname(current_dir)
1152
1153 if (os.path.exists(os.path.join(root_dir, ".git")) or
1154 os.path.exists(os.path.join(root_dir, ".hg")) or
1155 os.path.exists(os.path.join(root_dir, ".svn"))):
1156 prefix = os.path.commonprefix([root_dir, project_dir])
1157 return fullname[len(prefix) + 1:]
1158
1159 # Don't know what to do; header guard warnings may be wrong...
1160 return fullname
1161
1162 def Split(self):
1163 """Splits the file into the directory, basename, and extension.

Callers 6

SplitMethod · 0.95
CheckHeaderFileIncludedFunction · 0.95
CheckIncludeLineFunction · 0.95
FixupPathFromRootFunction · 0.80
_ClassifyIncludeFunction · 0.80

Calls 4

FullNameMethod · 0.95
dirnameMethod · 0.80
joinMethod · 0.65
existsMethod · 0.45

Tested by

no test coverage detected