From d91c454099141c34f5aa097d80aec80e085c1770 Mon Sep 17 00:00:00 2001 From: mihailkudravcev Date: Fri, 24 Jul 2026 10:38:25 +0300 Subject: [PATCH] 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 --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- export1c_help/export.py | 3 ++- export1c_help/wiki.py | 9 +++++++++ export_1c_help.py | 27 +++++++++++++++++++++++---- 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9ff2ae..a019ba1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to **export_1c_help** are documented in this file. +## [0.3.5] - 2026-07-24 + +### Fixed + +- `push -o …/out` no longer deletes `wiki_clone-*` during convert `--clean`, and does not copy the clone into itself (was `FileNotFoundError` on push) + ## [0.3.4] - 2026-07-24 ### Added diff --git a/VERSION b/VERSION index 42045ac..c2c0004 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.4 +0.3.5 diff --git a/export1c_help/export.py b/export1c_help/export.py index 45aa141..330d20a 100644 --- a/export1c_help/export.py +++ b/export1c_help/export.py @@ -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) diff --git a/export1c_help/wiki.py b/export1c_help/wiki.py index f792022..6129513 100644 --- a/export1c_help/wiki.py +++ b/export1c_help/wiki.py @@ -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) diff --git a/export_1c_help.py b/export_1c_help.py index 59fde4b..a506bcd 100644 --- a/export_1c_help.py +++ b/export_1c_help.py @@ -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,