(cwd: str | None = None)
| 99 | |
| 100 | |
| 101 | def get_default_branch(cwd: str | None = None) -> str: |
| 102 | head_ref = _run_git_ok(["symbolic-ref", "refs/remotes/origin/HEAD"], cwd) |
| 103 | if head_ref: |
| 104 | parts = head_ref.rsplit("/", 1) |
| 105 | if len(parts) == 2: |
| 106 | return parts[1] |
| 107 | |
| 108 | for candidate in ("main", "master", "develop"): |
| 109 | check = _run_git_ok(["rev-parse", "--verify", f"refs/heads/{candidate}"], cwd) |
| 110 | if check: |
| 111 | return candidate |
| 112 | |
| 113 | return "main" |
| 114 | |
| 115 | |
| 116 | def get_file_status(cwd: str | None = None) -> list[FileStatus]: |