Skip to content

Commit f8d0b32

Browse files
authored
fix: raise on placeholder prompt (#65)
1 parent 0a42eb7 commit f8d0b32

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/git_draft/__main__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,23 +146,23 @@ def on_list_files(
146146
def on_read_file(
147147
self, path: PurePosixPath, _contents: str | None, _reason: str | None
148148
) -> None:
149-
print(f"Reading {path!r}...")
149+
print(f"Reading {path}...")
150150

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

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

159159
def on_rename_file(
160160
self,
161161
src_path: PurePosixPath,
162162
dst_path: PurePosixPath,
163163
_reason: str | None
164164
) -> None:
165-
print(f"Renamed {src_path!r} to {dst_path!r}.")
165+
print(f"Renamed {src_path} to {dst_path}.")
166166

167167

168168
def edit(*, path: Path | None = None, text: str | None = None) -> str:
@@ -219,6 +219,8 @@ def main() -> None: # noqa: PLR0912 PLR0915
219219
prompt = edit(
220220
text=drafter.latest_draft_prompt() or _PROMPT_PLACEHOLDER
221221
)
222+
if not prompt or prompt == _PROMPT_PLACEHOLDER:
223+
raise ValueError("Aborting: empty or placeholder prompt")
222224
else:
223225
prompt = sys.stdin.read()
224226

tests/git_draft/drafter_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,17 @@ def test_generate_noop(self) -> None:
155155
def test_generate_accept_checkout(self) -> None:
156156
self._write("p1", "A")
157157
self._write("p2", "B")
158+
self._write("p4", "E")
158159
self._drafter.generate_draft(
159160
"hello",
160-
_SimpleBot({"p1": "C", "p3": "D"}),
161+
_SimpleBot({"p1": "C", "p3": "D", "p4": None}),
161162
accept=sut.Accept.CHECKOUT,
162163
sync=True,
163164
)
164165
assert self._read("p1") == "C"
165166
assert self._read("p2") == "B"
166167
assert self._read("p3") == "D"
168+
assert self._read("p4") is None
167169

168170
def test_generate_accept_checkout_conflict(self) -> None:
169171
self._write("p1", "A")

0 commit comments

Comments
 (0)