From 43849928ae1b510c07756a1650668adf70e8cb73 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Wed, 3 Feb 2016 10:33:14 +1030 Subject: [PATCH] For GitHub Enterprise environments, URLs must be relative (no leading slash). This was one of the cases we didn't notice, and so it causes the StatisticsClient to drop the /api/v3/ prefix that GitHub Enterprise requires to route things correctly. --- Octokit.Tests/Clients/StatisticsClientTests.cs | 10 +++++----- Octokit/Clients/StatisticsClient.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Octokit.Tests/Clients/StatisticsClientTests.cs b/Octokit.Tests/Clients/StatisticsClientTests.cs index 097ab7a6b1..f91429362b 100644 --- a/Octokit.Tests/Clients/StatisticsClientTests.cs +++ b/Octokit.Tests/Clients/StatisticsClientTests.cs @@ -24,7 +24,7 @@ public class TheGetContributorsMethod [Fact] public async Task RetrievesContributorsForCorrectUrl() { - var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/contributors", UriKind.Relative); + var expectedEndPoint = new Uri("repos/username/repositoryName/stats/contributors", UriKind.Relative); var client = Substitute.For(); IReadOnlyList contributors = new ReadOnlyCollection(new[] { new Contributor() }); client.GetQueuedOperation(expectedEndPoint, Args.CancellationToken) @@ -56,7 +56,7 @@ public class TheGetCommitActivityForTheLastYearMethod [Fact] public async Task RequestsCorrectUrl() { - var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/commit_activity", UriKind.Relative); + var expectedEndPoint = new Uri("repos/username/repositoryName/stats/commit_activity", UriKind.Relative); var data = new WeeklyCommitActivity(new[] { 1, 2 }, 100, 42); IReadOnlyList response = new ReadOnlyCollection(new[] { data }); @@ -94,7 +94,7 @@ public class TheGetAdditionsAndDeletionsPerWeekMethod [Fact] public async Task RequestsCorrectUrl() { - var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/code_frequency", UriKind.Relative); + var expectedEndPoint = new Uri("repos/username/repositoryName/stats/code_frequency", UriKind.Relative); long firstTimestamp = 159670861; long secondTimestamp = 0; @@ -139,7 +139,7 @@ public class TheGetWeeklyCommitCountsMethod [Fact] public void RequestsCorrectUrl() { - var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/participation", UriKind.Relative); + var expectedEndPoint = new Uri("repos/username/repositoryName/stats/participation", UriKind.Relative); var client = Substitute.For(); var statisticsClient = new StatisticsClient(client); @@ -169,7 +169,7 @@ public class TheGetHourlyCommitCountsMethod [Fact] public async Task RetrievesPunchCard() { - var expectedEndPoint = new Uri("/repos/username/repositoryName/stats/punch_card", UriKind.Relative); + var expectedEndPoint = new Uri("repos/username/repositoryName/stats/punch_card", UriKind.Relative); var client = Substitute.For(); IReadOnlyList data = new ReadOnlyCollection(new[] { new[] { 2, 8, 42 } }); diff --git a/Octokit/Clients/StatisticsClient.cs b/Octokit/Clients/StatisticsClient.cs index 35d81dfd11..f63a94ecaf 100644 --- a/Octokit/Clients/StatisticsClient.cs +++ b/Octokit/Clients/StatisticsClient.cs @@ -44,7 +44,7 @@ public async Task> GetContributors(string owner, stri Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - var endpoint = "/repos/{0}/{1}/stats/contributors".FormatUri(owner, repositoryName); + var endpoint = "repos/{0}/{1}/stats/contributors".FormatUri(owner, repositoryName); return await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); } @@ -71,7 +71,7 @@ public async Task GetCommitActivity(string owner, string reposit Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - var endpoint = "/repos/{0}/{1}/stats/commit_activity".FormatUri(owner, repositoryName); + var endpoint = "repos/{0}/{1}/stats/commit_activity".FormatUri(owner, repositoryName); var activity = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); return new CommitActivity(activity); } @@ -99,7 +99,7 @@ public async Task GetCodeFrequency(string owner, string repositor Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - var endpoint = "/repos/{0}/{1}/stats/code_frequency".FormatUri(owner, repositoryName); + var endpoint = "repos/{0}/{1}/stats/code_frequency".FormatUri(owner, repositoryName); var rawFrequencies = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); return new CodeFrequency(rawFrequencies); } @@ -127,7 +127,7 @@ public async Task GetParticipation(string owner, string repositor Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - var endpoint = "/repos/{0}/{1}/stats/participation".FormatUri(owner, repositoryName); + var endpoint = "repos/{0}/{1}/stats/participation".FormatUri(owner, repositoryName); var result = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); return result.FirstOrDefault(); } @@ -155,7 +155,7 @@ public async Task GetPunchCard(string owner, string repositoryName, C Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(repositoryName, "repositoryName"); - var endpoint = "/repos/{0}/{1}/stats/punch_card".FormatUri(owner, repositoryName); + var endpoint = "repos/{0}/{1}/stats/punch_card".FormatUri(owner, repositoryName); var punchCardData = await ApiConnection.GetQueuedOperation(endpoint, cancellationToken); return new PunchCard(punchCardData); }