fix: point imported docs' edit/view links at their own repository - #59
Merged
Merged
Conversation
An imported page's RelativePath is where it landed in this site, not where it lives upstream, so the site-wide repoUrl/editUri built an "edit this page" link into this repository at a path that only exists in the other one. Imported pages now carry their own SourceLinks, which the renderer treats as authoritative. They are resolved per source: an explicit repoUrl/editUri wins, otherwise both are derived from the clone -- the remote gives the host (an scp-style git@host:org/repo.git is rewritten to https), and the branch actually checked out plus sourcePath give the rest, so a source that never pinned a reference still gets correct links. When neither is possible -- a detached checkout with no branch to build a URL around, a remote that is a local path, or an S3 source with nothing configured -- the page renders no button rather than one that 404s, which is what the issue asked for. Also stops imported pages being stamped with today's date. git-revision-date reads this repository's history, finds nothing for a file outside it, and fell through to the filesystem -- reporting the moment the import cloned the file, so every imported page looked updated on every build. Pages whose source sits outside the repository are now left without git-derived dates. Fixes #58 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #58.
What & why
An imported page's
RelativePathis where it landed in this site (whereverdestinationPathput it), not where it lives upstream. The site-widerepoUrl/editUripattern therefore aimed "edit this page" at this repository, at a path that only exists in the other one:How links are resolved
Imported pages now carry their own
SourceLinks, which the renderer treats as authoritative. Per source:repoUrl+editUrion the source — always wins. This is the "options in the configuration to manually set the repo, and base path" the issue asked for, and the only option for S3 sources, which have no repository to derive from.git@host:org/repo.gitis rewritten to itshttps://form), and the branch actually checked out plussourcePathgive the rest. Reading the real branch means a source that never pinned areferencestill gets correct links, rather than us guessingmain.The date half of the issue
The issue guessed this "may also affect last edited by, created at" — it did.
git-revision-datereads this repo's history, finds nothing for a file outside it, and fell through to the filesystem timestamp. For imported content that timestamp is the moment the import cloned the file, so every imported page reported itself as updated today, on every build. Pages sourced from outside the repository now get no git-derived dates instead of a fabricated one.Type of change
Checklist
dotnet format Netdocs.slnx --verify-no-changespassesdotnet build Netdocs.slnx -c Releasesucceedsdotnet test Netdocs.slnx -c Releasepasses (553, +21 new)docs-site/docs/**if behavior changedVerification
Unit tests cover clone-URL rewriting (https/ssh/scp forms, and refusing to guess a host for a local path), derivation, explicit-config precedence, and every suppression case. Four more render a page through the real template engine to check what actually reaches the HTML.
Then end to end, with a real git repo imported into a real site:
org/site/edit/main/docs/index.mdorg/handbook/edit/main/docs/guides/setup.mdMutation-checked: disabling the renderer branch fails exactly the two tests that assert imported behaviour, and nothing else.
Notes for reviewers
SourceLinksis deliberately a nullable record where the members are also nullable, because there are three distinct states: null means "use the site-wide pattern" (ordinary pages), a value with links means "use these", and a value with nulls means "this page has no source to link to". Collapsing the last two would bring the wrong-link bug back for any origin we cannot resolve.The theme still gates the buttons behind the
content.action.edit/content.action.viewfeatures, unchanged.🤖 Generated with Claude Code