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
+23 -4
View File
@@ -242,12 +242,27 @@ def cmd_push(args: argparse.Namespace) -> int:
return 1
slug = slug_for_path(src)
out = args.out or (TOOL_ROOT / "out" / f"wiki-md-{slug}")
work = args.work_dir or (TOOL_ROOT / "out" / f"wiki_clone-{slug}")
out = (args.out or (TOOL_ROOT / "out" / f"wiki-md-{slug}")).resolve()
work = (args.work_dir or (TOOL_ROOT / "out" / f"wiki_clone-{slug}")).resolve()
branch = args.branch
print(f"wiki_url: {wiki_url}")
print(f"src: {src}")
print(f"out: {out}")
print(f"work: {work}")
try:
work.relative_to(out)
except ValueError:
nested = False
else:
nested = work != out
if nested:
print(
"note: wiki clone is inside --out; "
"convert will keep wiki_clone* dirs and skip copying them into themselves",
file=sys.stderr,
)
try:
prepare_wiki_clone(wiki_url, work, branch=branch)
@@ -255,7 +270,9 @@ def cmd_push(args: argparse.Namespace) -> int:
print(f"wiki prepare failed:\n{exc}", file=sys.stderr)
return 1
prev = args.prev_manifest or (work / "manifest.json")
prev = args.prev_manifest
if prev is None and (work / "manifest.json").is_file():
prev = work / "manifest.json"
cfg = args.config_version or read_config_version(src)
stats = export_help(
@@ -265,7 +282,7 @@ def cmd_push(args: argparse.Namespace) -> int:
skip_empty=not args.keep_empty,
clean=True,
source_label=args.source_label or str(src),
prev_manifest_path=prev if Path(prev).is_file() else None,
prev_manifest_path=prev if prev and Path(prev).is_file() else None,
config_version=cfg,
)
print(
@@ -283,6 +300,8 @@ def cmd_push(args: argparse.Namespace) -> int:
f"({stats.pages_written} pages, +{stats.created_count}/~{stats.edited_count}/-{stats.deleted_count})"
)
try:
if not (work / ".git").exists():
prepare_wiki_clone(wiki_url, work, branch=branch)
push_wiki(
out,
wiki_url,