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:
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
All notable changes to **export_1c_help** are documented in this file.
|
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
|
## [0.3.4] - 2026-07-24
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -248,7 +248,8 @@ def export_help(
|
|||||||
|
|
||||||
if clean and out_dir.exists():
|
if clean and out_dir.exists():
|
||||||
for child in out_dir.iterdir():
|
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
|
continue
|
||||||
if child.is_dir():
|
if child.is_dir():
|
||||||
shutil.rmtree(child)
|
shutil.rmtree(child)
|
||||||
|
|||||||
@@ -126,12 +126,21 @@ def push_wiki(
|
|||||||
for src in content_dir.iterdir():
|
for src in content_dir.iterdir():
|
||||||
if src.name == ".git":
|
if src.name == ".git":
|
||||||
continue
|
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
|
dst = work_dir / src.name
|
||||||
if src.is_dir():
|
if src.is_dir():
|
||||||
if dst.exists():
|
if dst.exists():
|
||||||
shutil.rmtree(dst)
|
shutil.rmtree(dst)
|
||||||
shutil.copytree(src, dst)
|
shutil.copytree(src, dst)
|
||||||
else:
|
else:
|
||||||
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
|
|
||||||
_run(["git", "add", "-A"], cwd=work_dir)
|
_run(["git", "add", "-A"], cwd=work_dir)
|
||||||
|
|||||||
+23
-4
@@ -242,12 +242,27 @@ def cmd_push(args: argparse.Namespace) -> int:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
slug = slug_for_path(src)
|
slug = slug_for_path(src)
|
||||||
out = args.out or (TOOL_ROOT / "out" / f"wiki-md-{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}")
|
work = (args.work_dir or (TOOL_ROOT / "out" / f"wiki_clone-{slug}")).resolve()
|
||||||
branch = args.branch
|
branch = args.branch
|
||||||
|
|
||||||
print(f"wiki_url: {wiki_url}")
|
print(f"wiki_url: {wiki_url}")
|
||||||
print(f"src: {src}")
|
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:
|
try:
|
||||||
prepare_wiki_clone(wiki_url, work, branch=branch)
|
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)
|
print(f"wiki prepare failed:\n{exc}", file=sys.stderr)
|
||||||
return 1
|
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)
|
cfg = args.config_version or read_config_version(src)
|
||||||
|
|
||||||
stats = export_help(
|
stats = export_help(
|
||||||
@@ -265,7 +282,7 @@ def cmd_push(args: argparse.Namespace) -> int:
|
|||||||
skip_empty=not args.keep_empty,
|
skip_empty=not args.keep_empty,
|
||||||
clean=True,
|
clean=True,
|
||||||
source_label=args.source_label or str(src),
|
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,
|
config_version=cfg,
|
||||||
)
|
)
|
||||||
print(
|
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})"
|
f"({stats.pages_written} pages, +{stats.created_count}/~{stats.edited_count}/-{stats.deleted_count})"
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
if not (work / ".git").exists():
|
||||||
|
prepare_wiki_clone(wiki_url, work, branch=branch)
|
||||||
push_wiki(
|
push_wiki(
|
||||||
out,
|
out,
|
||||||
wiki_url,
|
wiki_url,
|
||||||
|
|||||||
Reference in New Issue
Block a user