Fix push when --out contains the wiki clone directory.

Keep wiki_clone* across convert --clean and skip copying the clone into itself (0.3.5).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
mihailkudravcev
2026-07-24 10:38:25 +03:00
parent f9e8380348
commit d91c454099
5 changed files with 41 additions and 6 deletions
+2 -1
View File
@@ -248,7 +248,8 @@ def export_help(
if clean and out_dir.exists():
for child in out_dir.iterdir():
if child.name == ".git":
if child.name == ".git" or child.name.startswith("wiki_clone"):
# never wipe an in-tree wiki working clone
continue
if child.is_dir():
shutil.rmtree(child)
+9
View File
@@ -126,12 +126,21 @@ def push_wiki(
for src in content_dir.iterdir():
if src.name == ".git":
continue
# -o pointed at parent of the clone: do not copy the clone into itself
try:
if src.resolve() == work_dir.resolve():
continue
src.resolve().relative_to(work_dir.resolve())
continue # src is inside work_dir
except ValueError:
pass
dst = work_dir / src.name
if src.is_dir():
if dst.exists():
shutil.rmtree(dst)
shutil.copytree(src, dst)
else:
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, dst)
_run(["git", "add", "-A"], cwd=work_dir)