Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

ParseTreeUrl was not extracting subdirectory paths from URLs, and LoadTreeContentsFromUrlAsync always returned repository root contents regardless of the subdirectory specified in the URL.

Changes

ParseTreeUrl

  • Extract subdirectory path from URLs (e.g., /tree/main/implement/GitCore["implement", "GitCore"])
  • Add SubdirectoryPath field to ParseTreeUrlResult record
  • Use explicit property names in record construction

LoadTreeContentsFromUrlAsync

  • Route to LoadSubdirectoryContentsFromGitUrlAsync when subdirectory is specified
  • Fall back to root loading when no subdirectory present

Example

// Previously, this would return entire repository root:
var contents = await LoadFromUrl.LoadTreeContentsFromUrlAsync(
    "https://github.com/Viir/GitCore/tree/main/implement/GitCore");

// Now correctly returns only files from implement/GitCore subdirectory
// Returns 9 files instead of the full repository

Tests added for both URL parsing (7 unit tests) and subdirectory loading (2 integration tests).

Original prompt

Fix bugs in LoadTreeContentsFromUrlAsync and ParseTreeUrl:

  • ParseTreeUrl should also return the subdirectory from the URL. Add unit tests, at least for these two cases: "https://github.com/Viir/GitCore/tree/main/implement/GitCore", "https://github.com/Viir/GitCore/tree/95e147221ccae4d8609f02f132fc57f87adc135a/implement/GitCore"
  • Also, ParseTreeUrl should explicitly specify property names when constructing a record.
  • Fix the bug in LoadTreeContentsFromUrlAsync that causes it to return the contents of the repo root, instead of the specified subdirectory (e.g. with the URLs mentioned above) Add an integration test which verifies that it finds at least one file with the expected subsequence of path elements in the dictionary returned by LoadTreeContentsFromUrlAsync. Also assert the count of entries matches the expectation for the subdirectory.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…tories

Co-authored-by: Viir <19209696+Viir@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bugs in LoadTreeContentsFromUrlAsync and ParseTreeUrl Fix ParseTreeUrl and LoadTreeContentsFromUrlAsync to handle subdirectory paths Nov 10, 2025
Copilot AI requested a review from Viir November 10, 2025 12:09
@github-actions
Copy link

Test Results Overview macos-14

37 tests  +8   37 ✅ +8   8s ⏱️ +3s
 2 suites ±0    0 💤 ±0 
 2 files   ±0    0 ❌ ±0 

Results for commit d3e8b13. ± Comparison against base commit 95e1472.

@github-actions
Copy link

Test Results Overview ubuntu-24.04

37 tests  +8   37 ✅ +8   5s ⏱️ -1s
 2 suites ±0    0 💤 ±0 
 2 files   ±0    0 ❌ ±0 

Results for commit d3e8b13. ± Comparison against base commit 95e1472.

@Viir Viir marked this pull request as ready for review November 10, 2025 12:23
@Viir Viir merged commit 27b05c1 into main Nov 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants