MCPcopy Create free account
hub / github.com/ElementsProject/elements / check_or_create_worktree

Function check_or_create_worktree

contrib/review-prs.py:220–231  ·  view source on GitHub ↗

Verify that a git worktree (or repo) exists at `path`. Offer to create it if missing. Exit if something is wrong.

(path)

Source from the content-addressed store, hash-verified

218 commit["merged_cid"] = full_merged_cid
219
220def 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
233def main() -> None:
234 """Interactively review commits."""

Callers 1

mainFunction · 0.85

Calls 3

shell_onelineFunction · 0.85
prompt_charsFunction · 0.85
shellFunction · 0.85

Tested by

no test coverage detected