MCPcopy Index your code
hub / github.com/usestrix/strix / _resolve_base_ref

Function _resolve_base_ref

strix/interface/utils.py:648–675  ·  view source on GitHub ↗
(repo_path: Path, diff_base: str | None, env: dict[str, str])

Source from the content-addressed store, hash-verified

646
647
648def _resolve_base_ref(repo_path: Path, diff_base: str | None, env: dict[str, str]) -> str:
649 if diff_base and diff_base.strip():
650 return diff_base.strip()
651
652 github_base_ref = env.get("GITHUB_BASE_REF", "").strip()
653 if github_base_ref:
654 github_candidate = f"refs/remotes/origin/{github_base_ref}"
655 if _git_ref_exists(repo_path, github_candidate):
656 return github_candidate
657
658 github_base_sha = _extract_github_base_sha(env)
659 if github_base_sha and _git_ref_exists(repo_path, github_base_sha):
660 return github_base_sha
661
662 origin_head = _resolve_origin_head_ref(repo_path)
663 if origin_head and _git_ref_exists(repo_path, origin_head):
664 return origin_head
665
666 if _git_ref_exists(repo_path, "refs/remotes/origin/main"):
667 return "refs/remotes/origin/main"
668
669 if _git_ref_exists(repo_path, "refs/remotes/origin/master"):
670 return "refs/remotes/origin/master"
671
672 raise ValueError(
673 "Unable to resolve a base ref for diff-scope. Pass --diff-base explicitly "
674 "(for example: --diff-base origin/main)."
675 )
676
677
678def _get_current_branch_name(repo_path: Path) -> str | None:

Callers 1

_resolve_repo_diff_scopeFunction · 0.85

Calls 3

_git_ref_existsFunction · 0.85
_extract_github_base_shaFunction · 0.85
_resolve_origin_head_refFunction · 0.85

Tested by

no test coverage detected