| @@ 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 = """ |
|
| @@ 107-129 (lines=23) @@ | ||
| 104 | return stdout, p.returncode |
|
| 105 | ||
| 106 | ||
| 107 | def versions_from_parentdir(parentdir_prefix, root, verbose): |
|
| 108 | """Try to determine the version from the parent directory name. |
|
| 109 | ||
| 110 | Source tarballs conventionally unpack into a directory that includes both |
|
| 111 | the project name and a version string. We will also support searching up |
|
| 112 | two directory levels for an appropriately named parent directory |
|
| 113 | """ |
|
| 114 | rootdirs = [] |
|
| 115 | ||
| 116 | for i in range(3): |
|
| 117 | dirname = os.path.basename(root) |
|
| 118 | if dirname.startswith(parentdir_prefix): |
|
| 119 | return {"version": dirname[len(parentdir_prefix):], |
|
| 120 | "full-revisionid": None, |
|
| 121 | "dirty": False, "error": None, "date": None} |
|
| 122 | else: |
|
| 123 | rootdirs.append(root) |
|
| 124 | root = os.path.dirname(root) # up a level |
|
| 125 | ||
| 126 | if verbose: |
|
| 127 | print("Tried directories %s but none started with prefix %s" % |
|
| 128 | (str(rootdirs), parentdir_prefix)) |
|
| 129 | raise NotThisMethod("rootdir doesn't start with parentdir_prefix") |
|
| 130 | ||
| 131 | ||
| 132 | @register_vcs_handler("git", "get_keywords") |
|