Absolute shared `.git` directory for repo_root. Uses `rev-parse --git-common-dir` so linked worktrees resolve to the SHARED gitdir, not the per-worktree `.git/worktrees/ /`. That way push-sweep's reviewed-shas record (and the bash-hook-once sentinel) is per-clone — a commit rev
(repo_root)
| 154 | |
| 155 | |
| 156 | def _git_dir(repo_root): |
| 157 | """Absolute shared `.git` directory for repo_root. |
| 158 | |
| 159 | Uses `rev-parse --git-common-dir` so linked worktrees resolve to the |
| 160 | SHARED gitdir, not the per-worktree `.git/worktrees/<name>/`. That way |
| 161 | push-sweep's reviewed-shas record (and the bash-hook-once sentinel) |
| 162 | is per-clone — a commit reviewed in one worktree counts as reviewed |
| 163 | if a different worktree later pushes it. Returns None on failure so |
| 164 | callers can degrade (push-sweep state is best-effort). |
| 165 | """ |
| 166 | try: |
| 167 | r = subprocess.run( |
| 168 | [*GIT_CMD, "rev-parse", "--git-common-dir"], |
| 169 | cwd=repo_root, capture_output=True, text=True, timeout=5, |
| 170 | ) |
| 171 | if r.returncode != 0: |
| 172 | return None |
| 173 | d = r.stdout.strip() |
| 174 | return d if os.path.isabs(d) else os.path.join(repo_root, d) |
| 175 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError): |
| 176 | return None |
| 177 | |
| 178 | |
| 179 | def _git_rev_list_range(repo_root, base, head="HEAD"): |
no outgoing calls
no test coverage detected