publish-wiki: send titles with spaces so Gitea stores Home-da.md
TirSystem/github-action: Publish wiki / publish-wiki (push) Skipped
TirSystem/github-action: Sync GitHub mirror metadata / sync-metadata (push) Skipped
Validate workflows / validate (pull_request) Successful in 18s
TirSystem/github-action: Publish wiki / publish-wiki (push) Skipped
TirSystem/github-action: Sync GitHub mirror metadata / sync-metadata (push) Skipped
Validate workflows / validate (pull_request) Successful in 18s
Gitea keeps a hyphen in a page title literal and stored Home-da as Home-da.-.md, addressed as Home%2Dda, so a link to Home-da found no page. The publisher now sends the key with hyphens replaced by spaces. Task: MIL-006#6 Closes #119
This commit is contained in:
@@ -31,6 +31,14 @@ Each release lists its changes in these groups, in this order:
|
||||
`framework/scripts/ci-publish-milestones.sh`. No change for callers of the
|
||||
shared workflows.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `publish-wiki` sends a page title with spaces instead of hyphens. Gitea keeps a
|
||||
hyphen in a title literal and stored `Home-da` as `Home-da.-.md`, addressed as
|
||||
`Home%2Dda`, so links to `Home-da` led to the page list. A new page is now
|
||||
stored as `Home-da.md` and addressed as `Home-da`. Pages already created with
|
||||
the old title must be deleted by hand (the publisher does not prune them).
|
||||
|
||||
## [1.1.0] - 2026-10-11
|
||||
|
||||
### Added
|
||||
|
||||
@@ -67,6 +67,15 @@ class TestReadPages:
|
||||
publish_wiki.read_pages(tmp_path)
|
||||
|
||||
|
||||
class TestPageTitle:
|
||||
@pytest.mark.parametrize(
|
||||
("key", "title"), [("Home", "Home"), ("Home-da", "Home da"), ("Getting-Started-ms", "Getting Started ms")]
|
||||
)
|
||||
def test_a_hyphen_is_sent_as_a_space(self, publish_wiki, key, title):
|
||||
# Gitea keeps a hyphen in a title literal (Home-da.-.md, address Home%2Dda).
|
||||
assert publish_wiki.page_title(key) == title
|
||||
|
||||
|
||||
class TestPageKey:
|
||||
@pytest.mark.parametrize(
|
||||
("name", "key"),
|
||||
@@ -107,12 +116,13 @@ class FakeGitea:
|
||||
raise self.error("configuration", "404")
|
||||
return [{"title": key.replace("-", " "), "sub_url": key} for key in self.wiki]
|
||||
if method == "POST" and url == f"{WIKI_URL}/new":
|
||||
self.wiki[body["title"]] = body["content_base64"]
|
||||
self.wiki[body["title"].replace(" ", "-")] = body["content_base64"]
|
||||
return None
|
||||
title = url.rsplit("/", 1)[-1]
|
||||
if method == "GET":
|
||||
return {"title": title, "content_base64": self.wiki[title]}
|
||||
if method == "PATCH":
|
||||
assert " " in body["title"] or "-" not in body["title"], body["title"]
|
||||
self.wiki[title] = body["content_base64"]
|
||||
return None
|
||||
if method == "DELETE":
|
||||
|
||||
+11
-1
@@ -135,6 +135,16 @@ def page_key(title):
|
||||
return str(title).replace(" ", "-")
|
||||
|
||||
|
||||
def page_title(key):
|
||||
"""Return the title to send to Gitea for a page key.
|
||||
|
||||
A hyphen in a title is a literal hyphen to Gitea, which then stores the page
|
||||
as Home-da.-.md and addresses it as Home%2Dda, so a link to Home-da finds
|
||||
nothing. A space is stored as a hyphen (Home-da.md) and addressed as Home-da.
|
||||
"""
|
||||
return key.replace("-", " ")
|
||||
|
||||
|
||||
def read_pages(wiki_dir):
|
||||
"""Return {page key: content} for every Markdown file in wiki_dir."""
|
||||
pages = {}
|
||||
@@ -207,7 +217,7 @@ def publish(pages, wiki_url, headers, send, prune):
|
||||
result = {"created": [], "updated": [], "deleted": [], "kept": []}
|
||||
for title, content in pages.items():
|
||||
body = {
|
||||
"title": title,
|
||||
"title": page_title(title),
|
||||
"content_base64": base64.b64encode(content).decode("ascii"),
|
||||
"message": COMMIT_MESSAGE,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user