Skip to content

Commit

Permalink
For GitHub Enterprise environments, URLs must be relative (no leading…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
shiftkey committed Feb 3, 2016
1 parent b70dca4 commit 3d7a20c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Octokit.Tests/Clients/StatisticsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IApiConnection>();
IReadOnlyList<Contributor> contributors = new ReadOnlyCollection<Contributor>(new[] { new Contributor() });
client.GetQueuedOperation<Contributor>(expectedEndPoint, Args.CancellationToken)
Expand Down Expand Up @@ -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<WeeklyCommitActivity> response = new ReadOnlyCollection<WeeklyCommitActivity>(new[] { data });
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<IApiConnection>();
var statisticsClient = new StatisticsClient(client);
Expand Down Expand Up @@ -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<IApiConnection>();
IReadOnlyList<int[]> data = new ReadOnlyCollection<int[]>(new[] { new[] { 2, 8, 42 } });
Expand Down
10 changes: 5 additions & 5 deletions Octokit/Clients/StatisticsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task<IReadOnlyList<Contributor>> 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<Contributor>(endpoint, cancellationToken);
}

Expand All @@ -71,7 +71,7 @@ public async Task<CommitActivity> 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<WeeklyCommitActivity>(endpoint, cancellationToken);
return new CommitActivity(activity);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public async Task<CodeFrequency> 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<long[]>(endpoint, cancellationToken);
return new CodeFrequency(rawFrequencies);
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<Participation> 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<Participation>(endpoint, cancellationToken);
return result.FirstOrDefault();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public async Task<PunchCard> 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<int[]>(endpoint, cancellationToken);
return new PunchCard(punchCardData);
}
Expand Down

0 comments on commit 3d7a20c

Please sign in to comment.