MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / create_release_branch

Function create_release_branch

scripts/prepare_release.py:262–290  ·  view source on GitHub ↗

Create a release branch from the updated base branch. Args: version: Release version without the leading `v`. base_branch: Base branch to release from. remote: Remote name used for fetching and fast-forward pulls. Returns: Created release branch name. R

(version: str, base_branch: str, remote: str)

Source from the content-addressed store, hash-verified

260
261
262def create_release_branch(version: str, base_branch: str, remote: str) -> str:
263 """Create a release branch from the updated base branch.
264
265 Args:
266 version: Release version without the leading `v`.
267 base_branch: Base branch to release from.
268 remote: Remote name used for fetching and fast-forward pulls.
269
270 Returns:
271 Created release branch name.
272
273 Raises:
274 ReleaseError: The branch already exists or Git cannot create it.
275 """
276 branch = f"release/{version}"
277 git(["checkout", base_branch])
278 git(["pull", "--ff-only", remote, base_branch])
279 git(["fetch", "--tags", remote])
280
281 local_branch = git(["branch", "--list", branch], capture_output=True)
282 if local_branch:
283 raise ReleaseError(f"Local branch already exists: {branch}")
284
285 remote_branch = git(["ls-remote", "--heads", remote, branch], capture_output=True)
286 if remote_branch:
287 raise ReleaseError(f"Remote branch already exists: {remote}/{branch}")
288
289 git(["switch", "-c", branch])
290 return branch
291
292
293def run_validation(args: argparse.Namespace) -> None:

Callers 1

mainFunction · 0.85

Calls 2

gitFunction · 0.85
ReleaseErrorClass · 0.85

Tested by

no test coverage detected