feat: add scan --replace to take over tags removed in other apps
This commit is contained in:
parent
8a19f5f0af
commit
af89f9ed9b
5 changed files with 35 additions and 11 deletions
|
|
@ -57,3 +57,10 @@ def test_purge_keeps_config(otag, tmp_path):
|
|||
otag('p')
|
||||
assert not (tmp_path / orvani.CONTEXT_FILE).exists()
|
||||
assert (tmp_path / orvani.CONFIG_FILE).exists()
|
||||
|
||||
|
||||
def test_scan_replace(otag, tmp_path):
|
||||
(tmp_path / 'a.py').write_text('# otag: #one\n')
|
||||
(tmp_path / orvani.CONTEXT_FILE).write_text('a.py --- #one #gone\n')
|
||||
otag('s', '--replace')
|
||||
assert (tmp_path / orvani.CONTEXT_FILE).read_text() == 'a.py --- #one\n'
|
||||
|
|
|
|||
|
|
@ -71,3 +71,13 @@ def test_rst_is_not_handled(cwd):
|
|||
with pytest.raises(UnsupportedType):
|
||||
o.write_metadata('doc.rst', 'frontmatter')
|
||||
assert (cwd / 'doc.rst').read_text() == 'Title\n=====\n'
|
||||
|
||||
|
||||
def test_scan_replace_drops_tags_the_file_no_longer_has(cwd):
|
||||
(cwd / 'a.md').write_text('---\ntags: [one]\n---\n')
|
||||
(cwd / 'b.md').write_text('no front matter\n')
|
||||
(cwd / orvani.CONTEXT_FILE).write_text('a.md --- #one #gone\nb.md --- #kept\n')
|
||||
OrvaniTag().scan('.', False)
|
||||
assert (cwd / orvani.CONTEXT_FILE).read_text() == 'a.md --- #one #gone\nb.md --- #kept\n'
|
||||
OrvaniTag().scan('.', False, replace=True)
|
||||
assert (cwd / orvani.CONTEXT_FILE).read_text() == 'a.md --- #one\nb.md --- #kept\n'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue