Skip to content

Commit d3e8b13

Browse files
committed
avoid redundant
1 parent 2ae37e7 commit d3e8b13

2 files changed

Lines changed: 9 additions & 21 deletions

File tree

implement/GitCore.IntegrationTests/LoadTreeContentsFromGitHubTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ public async Task Load_subdirectory_tree_from_url_with_commit_sha()
7474
subdirectoryContents.Count.Should().Be(9, "Subdirectory should contain 9 files");
7575

7676
// Verify specific files exist in the subdirectory
77-
subdirectoryContents.Keys.Should().Contain(key => key.SequenceEqual(new[] { "GitObjects.cs" }),
78-
"Should contain GitObjects.cs");
77+
subdirectoryContents.Should().ContainKey(["GitObjects.cs"]);
7978

80-
subdirectoryContents.Keys.Should().Contain(key => key.SequenceEqual(new[] { "LoadFromUrl.cs" }),
81-
"Should contain LoadFromUrl.cs");
79+
subdirectoryContents.Should().ContainKey(["LoadFromUrl.cs"]);
8280
}
8381

8482
[Fact]

implement/GitCore/LoadFromUrl.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,14 @@ await GitSmartHttp.FetchBranchCommitShaAsync(
4646
httpClient);
4747
}
4848

49-
// Check if a subdirectory is specified
50-
if (parsed.SubdirectoryPath is not null && parsed.SubdirectoryPath.Count > 0)
51-
{
52-
// Load only the subdirectory contents
53-
var gitUrl = $"{parsed.BaseUrl}/{parsed.Owner}/{parsed.Repo}.git";
54-
55-
return await LoadSubdirectoryContentsFromGitUrlAsync(
56-
gitUrl,
57-
commitSha,
58-
parsed.SubdirectoryPath,
59-
httpClient);
60-
}
61-
62-
// Fetch the pack file containing the commit and its tree
63-
var packFileData =
64-
await GitSmartHttp.FetchPackFileAsync(parsed.BaseUrl, parsed.Owner, parsed.Repo, commitSha, httpClient);
49+
// Load only the subdirectory contents
50+
var gitUrl = $"{parsed.BaseUrl}/{parsed.Owner}/{parsed.Repo}.git";
6551

66-
return LoadTreeContentsFromPackFile(packFileData, commitSha);
52+
return await LoadSubdirectoryContentsFromGitUrlAsync(
53+
gitUrl,
54+
commitSha,
55+
parsed.SubdirectoryPath ?? [],
56+
httpClient);
6757
}
6858

6959
/// <summary>

0 commit comments

Comments
 (0)