Skip to content

Commit

Permalink
Fix RepositoryCommitsClient.GetSha1 API call after preview period end…
Browse files Browse the repository at this point in the history
…ed (octokit#1654)

* Change GetSha1 for commit API call to use official media type accept header rather than preview header (which doesn't seem to work anymore)

* Missed 2 unit tests
  • Loading branch information
ryangribble authored Aug 19, 2017
1 parent 7114bcb commit 951ca4f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Octokit.Tests/Clients/RepositoriesClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ public void RequestsTheCorrectUrl()
client.GetSha1("owner", "name", "reference");

connection.Received()
.Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null, AcceptHeaders.CommitReferenceSha1Preview);
.Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/commits/reference"), null, "application/vnd.github.v3.sha");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Octokit.Tests/Clients/RespositoryCommitsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public async Task RequestsCorrectUrl()
await client.GetSha1("fake", "repo", "ref");

connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/commits/ref"),
null, "application/vnd.github.chitauri-preview+sha");
null, "application/vnd.github.v3.sha");
}

[Fact]
Expand All @@ -330,7 +330,7 @@ public async Task RequestsCorrectUrlWithRepositoryId()
await client.GetSha1(1, "ref");

connection.Received().Get<string>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/commits/ref"),
null, "application/vnd.github.chitauri-preview+sha");
null, "application/vnd.github.v3.sha");
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Clients/RepositoryCommitsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public Task<string> GetSha1(string owner, string name, string reference)
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(owner, name, reference), null, AcceptHeaders.CommitReferenceSha1Preview);
return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(owner, name, reference), null, AcceptHeaders.CommitReferenceSha1MediaType);
}

/// <summary>
Expand All @@ -202,7 +202,7 @@ public Task<string> GetSha1(long repositoryId, string reference)
{
Ensure.ArgumentNotNullOrEmptyString(reference, "reference");

return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(repositoryId, reference), null, AcceptHeaders.CommitReferenceSha1Preview);
return ApiConnection.Get<string>(ApiUrls.RepositoryCommit(repositoryId, reference), null, AcceptHeaders.CommitReferenceSha1MediaType);
}
}
}
6 changes: 3 additions & 3 deletions Octokit/Helpers/AcceptHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static class AcceptHeaders

public const string RedirectsPreviewThenStableVersionJson = "application/vnd.github.quicksilver-preview+json; charset=utf-8, application/vnd.github.v3+json; charset=utf-8";

public const string CommitReferenceSha1MediaType = "application/vnd.github.v3.sha";

public const string OrganizationPermissionsPreview = "application/vnd.github.ironman-preview+json";

public const string LicensesApiPreview = "application/vnd.github.drax-preview+json";
Expand All @@ -19,9 +21,7 @@ public static class AcceptHeaders
public const string StarCreationTimestamps = "application/vnd.github.v3.star+json";

public const string IssueLockingUnlockingApiPreview = "application/vnd.github.the-key-preview+json";

public const string CommitReferenceSha1Preview = "application/vnd.github.chitauri-preview+sha";


public const string SquashCommitPreview = "application/vnd.github.polaris-preview+json";

public const string MigrationsApiPreview = "application/vnd.github.wyandotte-preview+json";
Expand Down

0 comments on commit 951ca4f

Please sign in to comment.