diff --git a/fieldnotes/cli.py b/fieldnotes/cli.py index 9427a92..94a2666 100644 --- a/fieldnotes/cli.py +++ b/fieldnotes/cli.py @@ -35,6 +35,7 @@ notes_referencing, parse_note_file, read_note, + serialize_note, to_repo_relative, write_note, ) @@ -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: diff --git a/tests/test_cli_v09_update.py b/tests/test_cli_v09_update.py index 70c4ef2..15dfe2a 100644 --- a/tests/test_cli_v09_update.py +++ b/tests/test_cli_v09_update.py @@ -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