Track configuration version and page lifecycle in wiki export.
Record created/edited/deleted-in versions per page; add History.md and update workflow docs.
This commit is contained in:
+37
-15
@@ -26,24 +26,14 @@ def _run(cmd: list[str], *, cwd: Path) -> str:
|
||||
return proc.stdout
|
||||
|
||||
|
||||
def push_wiki(
|
||||
content_dir: Path,
|
||||
def prepare_wiki_clone(
|
||||
wiki_url: str,
|
||||
*,
|
||||
work_dir: Path,
|
||||
message: str,
|
||||
*,
|
||||
branch: str = "main",
|
||||
keep_unmanaged: bool = False,
|
||||
) -> None:
|
||||
"""
|
||||
Clone/fetch wiki repo into work_dir, replace managed pages, commit, push.
|
||||
|
||||
Managed pages = all *.md from content_dir plus images and manifest.json.
|
||||
If keep_unmanaged=False, removes other *.md (except maybe custom) before copy.
|
||||
"""
|
||||
content_dir = content_dir.resolve()
|
||||
) -> Path:
|
||||
"""Clone or reset wiki working tree; return path to existing manifest.json if any."""
|
||||
work_dir = work_dir.resolve()
|
||||
|
||||
if work_dir.exists() and (work_dir / ".git").exists():
|
||||
_run(["git", "fetch", "origin"], cwd=work_dir)
|
||||
_run(["git", "checkout", branch], cwd=work_dir)
|
||||
@@ -53,9 +43,41 @@ def push_wiki(
|
||||
shutil.rmtree(work_dir)
|
||||
work_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
_run(
|
||||
["git", "clone", "--branch", branch, "--single-branch", wiki_url, str(work_dir)],
|
||||
[
|
||||
"git",
|
||||
"clone",
|
||||
"--branch",
|
||||
branch,
|
||||
"--single-branch",
|
||||
wiki_url,
|
||||
str(work_dir),
|
||||
],
|
||||
cwd=work_dir.parent,
|
||||
)
|
||||
return work_dir
|
||||
|
||||
|
||||
def push_wiki(
|
||||
content_dir: Path,
|
||||
wiki_url: str,
|
||||
*,
|
||||
work_dir: Path,
|
||||
message: str,
|
||||
branch: str = "main",
|
||||
keep_unmanaged: bool = False,
|
||||
already_prepared: bool = False,
|
||||
) -> None:
|
||||
"""
|
||||
Clone/fetch wiki repo into work_dir, replace managed pages, commit, push.
|
||||
|
||||
Managed pages = all files from content_dir (md/json/images).
|
||||
If keep_unmanaged=False, removes other .md/.json/images before copy.
|
||||
"""
|
||||
content_dir = content_dir.resolve()
|
||||
work_dir = work_dir.resolve()
|
||||
|
||||
if not already_prepared:
|
||||
prepare_wiki_clone(wiki_url, work_dir, branch=branch)
|
||||
|
||||
if not keep_unmanaged:
|
||||
for path in work_dir.iterdir():
|
||||
|
||||
Reference in New Issue
Block a user