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
+6
View File
@@ -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
+1 -1
View File
@@ -1 +1 @@
0.3.4
0.3.5
+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)
+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,