Write API reference docs to the nearest .github, not the repo root#64
Merged
Conversation
The packed Trellis.ApiReference.targets copied the API-reference markdown to <gitRoot>/.github on build. In a repository whose subfolders are themselves projects (each with its own .github), building a subproject dumped the docs at the outer repo root instead of the subproject's own .github. Walk up from the project directory and copy to the NEAREST existing .github, bounded so the search never crosses above the .git repository root (so it cannot escape into an unrelated parent). If no .github exists between the project and the repo root, fall back to creating .github at the repo root - the previous behavior for a normal single-repo consumer. The TrellisApiReferenceRoot override is unchanged.
There was a problem hiding this comment.
Pull request overview
This PR updates the packed MSBuild targets (Trellis.ApiReference.targets) so API reference markdown is copied to the nearest existing .github/ directory above the project (but not above the .git repo root), instead of always targeting the outer repository root .github/. This helps multi-project repositories where subfolders are independent projects with their own .github/.
Changes:
- Adjust destination selection logic to prefer the nearest existing
.github/directory when syncing API reference docs. - Bound the upward search so it won’t select a
.github/above the nearest.gitrepository root. - Preserve the
TrellisApiReferenceRootoverride behavior while updating how the final output directory is derived.
Comment on lines
+112
to
+123
| <!-- Nearest existing .github at or below the repo root (first match wins). --> | ||
| <_TrellisNearestGitHub Condition="'$(_NoGitLt0)' == 'true' AND Exists('$(_Tp0GitHub)')">$(_Tp0GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt1)' == 'true' AND Exists('$(_Tp1GitHub)')">$(_Tp1GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt2)' == 'true' AND Exists('$(_Tp2GitHub)')">$(_Tp2GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt3)' == 'true' AND Exists('$(_Tp3GitHub)')">$(_Tp3GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt4)' == 'true' AND Exists('$(_Tp4GitHub)')">$(_Tp4GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt5)' == 'true' AND Exists('$(_Tp5GitHub)')">$(_Tp5GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt6)' == 'true' AND Exists('$(_Tp6GitHub)')">$(_Tp6GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt7)' == 'true' AND Exists('$(_Tp7GitHub)')">$(_Tp7GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt8)' == 'true' AND Exists('$(_Tp8GitHub)')">$(_Tp8GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt9)' == 'true' AND Exists('$(_Tp9GitHub)')">$(_Tp9GitHub)</_TrellisNearestGitHub> | ||
| <_TrellisNearestGitHub Condition="'$(_TrellisNearestGitHub)' == '' AND '$(_NoGitLt10)' == 'true' AND Exists('$(_Tp10GitHub)')">$(_Tp10GitHub)</_TrellisNearestGitHub> |
…id directory checks
…ty DoS vulnerability
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64 +/- ##
==========================================
+ Coverage 83.37% 83.52% +0.15%
==========================================
Files 24 24
Lines 439 443 +4
Branches 68 70 +2
==========================================
+ Hits 366 370 +4
Misses 56 56
Partials 17 17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Issue
The packed
Trellis.ApiReference.targetscopies the shipped API-reference markdown to<gitRoot>/.githubon build. In a repository whose subfolders are themselves projects - each with its own.github- building a subproject dumps the docs at the OUTER repo root instead of the subproject's own.github.Fix
Walk up from the project directory and copy to the nearest existing
.github, bounded so the search never crosses above the.gitrepository root (it cannot escape into an unrelated parent). If no.githubexists between the project and the repo root, fall back to creating.github/at the repo root - the previous behavior for a normal single-repo consumer. TheTrellisApiReferenceRootoverride is unchanged.Validation
This targets file is identical to the one shipped by the Trellis framework packages; the same change was validated there end-to-end through a packed consumer on a local feed plus an MSBuild harness (nearest-
.githubselected; root-only unchanged; no-.githubfalls back to root; a.githubabove the repo root is not selected; override honored).