Verify that a git worktree (or repo) exists at `path`. Offer to create it if missing. Exit if something is wrong.
(path)
| 218 | commit["merged_cid"] = full_merged_cid |
| 219 | |
| 220 | def check_or_create_worktree(path) -> None: |
| 221 | """Verify that a git worktree (or repo) exists at `path`. Offer to create it if missing. Exit if something is wrong.""" |
| 222 | |
| 223 | try: |
| 224 | shell_oneline(f"git -C {shlex.quote(path)} rev-parse --show-toplevel", suppress_stderr=True) |
| 225 | except CalledProcessError: |
| 226 | said = prompt_chars(f"No git worktree or repository found at '{path}'. Ok to create a worktree there?", "yn") |
| 227 | if said != "y": |
| 228 | sys.exit(1) |
| 229 | |
| 230 | # Can't create a worktree without something to check out -- this is an arbitrary choice (apparently the first commit in the bitcoin repo.) |
| 231 | shell(f"git worktree add {shlex.quote(path)} 4405b78d6059e536c36974088a8ed4d9f0f29898") |
| 232 | |
| 233 | def main() -> None: |
| 234 | """Interactively review commits.""" |
no test coverage detected