Some checks failed
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-container (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
The old test tests/unit/pkgmgr/actions/test_branch.py has been removed because: - it targeted the previous monolithic pkgmgr.actions.branch module structure - its patch targets no longer match the refactored code - its responsibilities are now fully covered by the new, dedicated unit, integration, and E2E tests for branch actions and CLI wiring This avoids redundant coverage and prevents misleading or broken tests after the branch refactor. https://chatgpt.com/share/693bcc8d-b84c-800f-8510-8d6c66faf627
28 lines
664 B
Python
28 lines
664 B
Python
from __future__ import annotations
|
|
from pkgmgr.core.git import run_git, GitError
|
|
|
|
|
|
def _resolve_base_branch(
|
|
preferred: str,
|
|
fallback: str,
|
|
cwd: str,
|
|
) -> str:
|
|
"""
|
|
Resolve the base branch to use.
|
|
|
|
Try `preferred` first (default: main),
|
|
fall back to `fallback` (default: master).
|
|
|
|
Raise RuntimeError if neither exists.
|
|
"""
|
|
for candidate in (preferred, fallback):
|
|
try:
|
|
run_git(["rev-parse", "--verify", candidate], cwd=cwd)
|
|
return candidate
|
|
except GitError:
|
|
continue
|
|
|
|
raise RuntimeError(
|
|
f"Neither {preferred!r} nor {fallback!r} exist in this repository."
|
|
)
|