From 0bcb155a0de83795e95c89f8fbe7414ec7c7532f Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 24 Feb 2020 18:00:12 -0400 Subject: [PATCH 1/2] add failing test for handling / as the path --- .../Clients/RepositoryContentsClientTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs index 2afea59ccf..d2283388b0 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryContentsClientTests.cs @@ -222,6 +222,18 @@ public async Task GetsDirectoryContent() Assert.Equal(ContentType.Dir, contents.First().Type); } + [IntegrationTest] + public async Task GetsContentNonMasterWithRootPath() + { + var github = Helper.GetAuthenticatedClient(); + + var contents = await github + .Repository + .Content + .GetAllContentsByRef("octocat", "Spoon-Knife", "/", reference: "test-branch"); + Assert.Equal(4, contents.Count); + } + [IntegrationTest] public async Task GetsDirectoryContentWithRepositoryId() { From 8e6f5ed7774eda385f4d9da472585baf9351f471 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 24 Feb 2020 18:02:58 -0400 Subject: [PATCH 2/2] workaround issue by passing in what the API expects --- Octokit/Clients/RepositoryContentsClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Octokit/Clients/RepositoryContentsClient.cs b/Octokit/Clients/RepositoryContentsClient.cs index 96056f67fd..92ccfd45e4 100644 --- a/Octokit/Clients/RepositoryContentsClient.cs +++ b/Octokit/Clients/RepositoryContentsClient.cs @@ -107,7 +107,9 @@ public Task> GetAllContentsByRef(string owner, Ensure.ArgumentNotNullOrEmptyString(path, nameof(path)); Ensure.ArgumentNotNullOrEmptyString(reference, nameof(reference)); - var url = ApiUrls.RepositoryContent(owner, name, path, reference); + var url = (path == "/") + ? ApiUrls.RepositoryContent(owner, name, "", reference) + : ApiUrls.RepositoryContent(owner, name, path, reference); return ApiConnection.GetAll(url); }