Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/git_draft/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,23 @@ def on_list_files(
def on_read_file(
self, path: PurePosixPath, _contents: str | None, _reason: str | None
) -> None:
print(f"Reading {path!r}...")
print(f"Reading {path}...")

def on_write_file(
self, path: PurePosixPath, _contents: str, _reason: str | None
) -> None:
print(f"Updated {path!r}.")
print(f"Wrote {path}.")

def on_delete_file(self, path: PurePosixPath, _reason: str | None) -> None:
print(f"Deleted {path!r}.")
print(f"Deleted {path}.")

def on_rename_file(
self,
src_path: PurePosixPath,
dst_path: PurePosixPath,
_reason: str | None
) -> None:
print(f"Renamed {src_path!r} to {dst_path!r}.")
print(f"Renamed {src_path} to {dst_path}.")


def edit(*, path: Path | None = None, text: str | None = None) -> str:
Expand Down Expand Up @@ -219,6 +219,8 @@ def main() -> None: # noqa: PLR0912 PLR0915
prompt = edit(
text=drafter.latest_draft_prompt() or _PROMPT_PLACEHOLDER
)
if not prompt or prompt == _PROMPT_PLACEHOLDER:
raise ValueError("Aborting: empty or placeholder prompt")
else:
prompt = sys.stdin.read()

Expand Down
4 changes: 3 additions & 1 deletion tests/git_draft/drafter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@ def test_generate_noop(self) -> None:
def test_generate_accept_checkout(self) -> None:
self._write("p1", "A")
self._write("p2", "B")
self._write("p4", "E")
self._drafter.generate_draft(
"hello",
_SimpleBot({"p1": "C", "p3": "D"}),
_SimpleBot({"p1": "C", "p3": "D", "p4": None}),
accept=sut.Accept.CHECKOUT,
sync=True,
)
assert self._read("p1") == "C"
assert self._read("p2") == "B"
assert self._read("p3") == "D"
assert self._read("p4") is None

def test_generate_accept_checkout_conflict(self) -> None:
self._write("p1", "A")
Expand Down