@@ 111-139 (lines=29) @@ | ||
108 | return stdout, p.returncode |
|
109 | ||
110 | ||
111 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
|
112 | """Try to determine the version from the parent directory name. |
|
113 | ||
114 | Source tarballs conventionally unpack into a directory that includes both |
|
115 | the project name and a version string. We will also support searching up |
|
116 | two directory levels for an appropriately named parent directory |
|
117 | """ |
|
118 | rootdirs = [] |
|
119 | ||
120 | for i in range(3): |
|
121 | dirname = os.path.basename(root) |
|
122 | if dirname.startswith(parentdir_prefix): |
|
123 | return { |
|
124 | "version": dirname[len(parentdir_prefix):], |
|
125 | "full-revisionid": None, |
|
126 | "dirty": False, |
|
127 | "error": None, |
|
128 | "date": None |
|
129 | } |
|
130 | else: |
|
131 | rootdirs.append(root) |
|
132 | root = os.path.dirname(root) # up a level |
|
133 | ||
134 | if verbose: |
|
135 | print( |
|
136 | "Tried directories %s but none started with prefix %s" % |
|
137 | (str(rootdirs), parentdir_prefix) |
|
138 | ) |
|
139 | raise NotThisMethod("rootdir doesn't start with parentdir_prefix") |
|
140 | ||
141 | ||
142 | @register_vcs_handler("git", "get_keywords") |
@@ 1158-1180 (lines=23) @@ | ||
1155 | run_command(GITS, ["add", "--"] + files) |
|
1156 | ||
1157 | ||
1158 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
|
1159 | """Try to determine the version from the parent directory name. |
|
1160 | ||
1161 | Source tarballs conventionally unpack into a directory that includes both |
|
1162 | the project name and a version string. We will also support searching up |
|
1163 | two directory levels for an appropriately named parent directory |
|
1164 | """ |
|
1165 | rootdirs = [] |
|
1166 | ||
1167 | for i in range(3): |
|
1168 | dirname = os.path.basename(root) |
|
1169 | if dirname.startswith(parentdir_prefix): |
|
1170 | return {"version": dirname[len(parentdir_prefix):], |
|
1171 | "full-revisionid": None, |
|
1172 | "dirty": False, "error": None, "date": None} |
|
1173 | else: |
|
1174 | rootdirs.append(root) |
|
1175 | root = os.path.dirname(root) # up a level |
|
1176 | ||
1177 | if verbose: |
|
1178 | print("Tried directories %s but none started with prefix %s" % |
|
1179 | (str(rootdirs), parentdir_prefix)) |
|
1180 | raise NotThisMethod("rootdir doesn't start with parentdir_prefix") |
|
1181 | ||
1182 | ||
1183 | SHORT_VERSION_PY = """ |