MCPcopy
hub / github.com/pytest-dev/pytest / find_next_version

Function find_next_version

scripts/prepare-release-pr.py:144–162  ·  view source on GitHub ↗
(
    base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
)

Source from the content-addressed store, hash-verified

142
143
144def find_next_version(
145 base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
146) -> str:
147 output = check_output(["git", "tag"], encoding="UTF-8")
148 valid_versions = []
149 for v in output.splitlines():
150 m = re.match(r"\d.\d.\d+$", v.strip())
151 if m:
152 valid_versions.append(tuple(int(x) for x in v.split(".")))
153
154 valid_versions.sort()
155 last_version = valid_versions[-1]
156
157 if is_major:
158 return f"{last_version[0] + 1}.0.0{prerelease}"
159 elif is_feature_release:
160 return f"{last_version[0]}.{last_version[1] + 1}.0{prerelease}"
161 else:
162 return f"{last_version[0]}.{last_version[1]}.{last_version[2] + 1}{prerelease}"
163
164
165def main() -> None:

Callers 1

prepare_release_prFunction · 0.85

Calls 4

intClass · 0.85
matchMethod · 0.80
stripMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected