mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
refactor: one autorun worktree path and checkout
This commit is contained in:
1 parent
6c92b0172e
commit
eec4ff9972
6 files changed
+29
-17
No files matched your search
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class GitRefused(RuntimeError):
|
||||
@@ -37,6 +38,17 @@ def required_git_lines(*args: str) -> list[str]:
|
||||
return _lines(result.stdout)
|
||||
|
||||
|
||||
def main_checkout(cwd: Path) -> Path:
|
||||
"""The main checkout of the clone holding cwd, also from a linked worktree,
|
||||
GitRefused when cwd is in no clone."""
|
||||
args = ("rev-parse", "--path-format=absolute", "--git-common-dir")
|
||||
result = _run(("-C", str(cwd), *args))
|
||||
if result.returncode:
|
||||
detail = result.stderr.strip() or f"exit {result.returncode}"
|
||||
raise GitRefused(f"git {' '.join(args)}: {detail}")
|
||||
return Path(result.stdout.strip()).parent
|
||||
|
||||
|
||||
# Where a clone with no remote naming the project keeps its main line, each
|
||||
# remote's names in the order tried.
|
||||
FALLBACK_REMOTES = ("upstream", "origin")
|
||||
|
||||
Reference in new issue
Block a user