Skip to content

Commit cc50187

Browse files
author
Lars Solberg
committed
Allow tag-dir to be inside source-directory
1 parent 1b346f2 commit cc50187

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

HISTORY.rst

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
History
33
=======
44

5+
0.18.0 (2019-12-07)
6+
-------------------
7+
8+
* Don't create symlinks if it's destination is in the symlink directory. This makes it possible to have the tag-directory inside the source-directory.
9+
510
0.17.1 (2019-12-06)
611
-------------------
712

taggo/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ def make_symlink(symlink_basepath, sourcepath, *, nametemplate=None, metadata_st
461461

462462
metadata_store = metadata_store or Metadata()
463463

464+
if sourcepath.startswith(symlink_basepath):
465+
log(f' * skipping, symlink is already in the destination directory', loglevel='debug')
466+
return
467+
464468
is_file = os.path.isfile(sourcepath)
465469

466470
metadata_store.add_multiple('path', _path_variants(os.path.dirname(sourcepath)))

tests/test_cli.py

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import os
55
import re
6+
import glob
67
import json
78
import shutil
89
import textwrap
@@ -91,6 +92,18 @@ def test_frontmatter(tmpdir):
9192
]:
9293
assert os.path.isfile(f"{tmpdir}/{filepath}")
9394

95+
def test_tagfolder_in_src(tmpdir):
96+
"""
97+
If the tag-destination is inside the source-directory, we must ignore it..
98+
"""
99+
tmp = f"{tmpdir}/tagfolder_in_source"
100+
shutil.copytree(f"{test_files}/tagfolder_in_source", tmp, symlinks=True)
101+
102+
for i in [0, 1]:
103+
taggo.main(["run", "--nametemplate", "{path.basename} - {path.hierarcy_str}", tmp, tmp + '/tags'])
104+
105+
assert len(glob.glob(tmp + '/tags/*')) == 1
106+
94107

95108
def test_existing_file_dst(tmpdir):
96109
tmppath = f"{tmpdir}/existing-file"

tests/test_files/tagfolder_in_source/src/aa #bb.md

Whitespace-only changes.

0 commit comments

Comments
 (0)