Skip to content
Open
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
3 changes: 2 additions & 1 deletion fieldnotes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
notes_referencing,
parse_note_file,
read_note,
serialize_note,
to_repo_relative,
write_note,
)
Expand Down Expand Up @@ -625,7 +626,7 @@ def verify(
rebase=do_rebase,
rebase_results=note_results if do_rebase else None,
)
write_note(repo_root, new_note, parse_note_file(s.path)[1])
s.path.write_text(serialize_note(new_note, parse_note_file(s.path)[1]))
rebase_results.extend(note_results)
changed = _changed_refs(s, note_results)
if changed:
Expand Down
18 changes: 18 additions & 0 deletions tests/test_cli_v09_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,21 @@ def test_clean_repo_prints_no_review_block(self, repo: Path):
result = runner.invoke(app, ["verify", "--update", "--repo", str(repo)])
assert result.exit_code == 0, result.output
assert "re-read" not in result.output


class TestUpdateWritesOriginalNotePath:
def test_update_keeps_mismatched_note_filename(self, repo: Path):
(repo / "f.py").write_text("x = 1\n")
_add(repo, "f.py")
original = next((repo / ".fieldnotes" / "notes").glob("0001-*.md"))
renamed = original.with_name("0001-t-renamed.md")
original.rename(renamed)
(repo / "f.py").write_text("x = 2\n")

result = runner.invoke(app, ["verify", "--update", "--repo", str(repo)])

assert result.exit_code == 0, result.output
note_files = sorted((repo / ".fieldnotes" / "notes").glob("0001-*.md"))
assert note_files == [renamed]
check = runner.invoke(app, ["verify", "--check", "--repo", str(repo)])
assert check.exit_code == 0, check.output