From cf442499ff5e5a4efe584a976a241f2b67fd7249 Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Wed, 30 Jan 2019 21:20:50 +1000 Subject: [PATCH] add RequiredApprovingReview preview functionality to branch protection calls (#1912) --- .../Clients/RepositoryBranchesClientTests.cs | 34 +++-- .../OrganizationRepositoryWithTeamContext.cs | 4 +- ...ObservableRepositoryBranchesClientTests.cs | 37 ++++-- .../Clients/RepositoryBranchesClientTests.cs | 122 +++++++++--------- ...ObservableRepositoryBranchesClientTests.cs | 6 +- Octokit/Clients/RepositoryBranchesClient.cs | 114 ++++++++-------- Octokit/Helpers/AcceptHeaders.cs | 2 + .../Models/Request/BranchProtectionUpdate.cs | 42 +++--- Octokit/Models/Response/BranchProtection.cs | 15 ++- 9 files changed, 213 insertions(+), 163 deletions(-) diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 5c5dba03a6..cbc465bb57 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -318,7 +318,7 @@ public async Task UpdatesBranchProtection() var repoName = _userRepoContext.RepositoryName; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); @@ -329,6 +329,7 @@ public async Task UpdatesBranchProtection() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -341,7 +342,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() var repoId = _userRepoContext.RepositoryId; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); var protection = await _client.UpdateBranchProtection(repoId, "master", update); @@ -352,6 +353,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -365,7 +367,7 @@ public async Task UpdatesBranchProtectionForOrgRepo() var repoName = _orgRepoContext.RepositoryContext.RepositoryName; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), false); @@ -377,6 +379,7 @@ public async Task UpdatesBranchProtectionForOrgRepo() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Empty(protection.Restrictions.Teams); Assert.Empty(protection.Restrictions.Users); @@ -390,7 +393,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() var repoId = _orgRepoContext.RepositoryContext.RepositoryId; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), false); @@ -402,6 +405,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Empty(protection.Restrictions.Teams); Assert.Empty(protection.Restrictions.Users); @@ -873,26 +877,28 @@ public async Task UpdatesReviewEnforcement() { var repoOwner = _userRepoContext.RepositoryOwner; var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate(false, true); + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] public async Task UpdatesReviewEnforcementWithRepositoryId() { var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate(false, true); + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -903,13 +909,15 @@ public async Task UpdatesReviewEnforcementForOrgRepo() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -919,13 +927,15 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -936,7 +946,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); @@ -944,6 +955,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() Assert.Empty(requiredReviews.DismissalRestrictions.Users); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -953,7 +965,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); @@ -961,6 +974,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI Assert.Empty(requiredReviews.DismissalRestrictions.Users); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } public void Dispose() diff --git a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs index 7322913bda..8c36d50389 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs @@ -32,7 +32,7 @@ internal async static Task CreateRepositoryWithProtectedBranc // Protect master branch var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), - new BranchProtectionRequiredReviewsUpdate(true, true), + new BranchProtectionRequiredReviewsUpdate(true, true, 3), null, true); @@ -60,7 +60,7 @@ await client.Organization.Team.AddRepository( // Protect master branch var protection = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true, true), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true, true, 3), new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection { contextOrgTeam.TeamName }), true); await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "master", protection); diff --git a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs index db4ea1b58e..8cbac07c59 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -38,6 +38,7 @@ public async Task GetsBranchProtection() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -56,6 +57,7 @@ public async Task GetsBranchProtectionWithRepositoryId() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -76,6 +78,7 @@ public async Task GetsBranchProtectionForOrgRepo() Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Equal(1, protection.Restrictions.Teams.Count); Assert.Equal(0, protection.Restrictions.Users.Count); @@ -96,6 +99,7 @@ public async Task GetsBranchProtectionForOrgRepoWithRepositoryId() Assert.Equal(0, protection.RequiredPullRequestReviews.DismissalRestrictions.Users.Count); Assert.True(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(3, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Equal(1, protection.Restrictions.Teams.Count); Assert.Equal(0, protection.Restrictions.Users.Count); @@ -135,7 +139,7 @@ public async Task UpdatesBranchProtection() var repoName = _userRepoContext.RepositoryName; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); var protection = await _client.UpdateBranchProtection(repoOwner, repoName, "master", update); @@ -146,6 +150,7 @@ public async Task UpdatesBranchProtection() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -158,7 +163,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() var repoId = _userRepoContext.RepositoryId; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(false, true), + new BranchProtectionRequiredReviewsUpdate(false, true, 2), false); var protection = await _client.UpdateBranchProtection(repoId, "master", update); @@ -169,6 +174,7 @@ public async Task UpdatesBranchProtectionWithRepositoryId() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.True(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Null(protection.Restrictions); @@ -182,7 +188,7 @@ public async Task UpdatesBranchProtectionForOrgRepo() var repoName = _orgRepoContext.RepositoryContext.RepositoryName; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), false); @@ -194,6 +200,7 @@ public async Task UpdatesBranchProtectionForOrgRepo() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Empty(protection.Restrictions.Teams); Assert.Empty(protection.Restrictions.Users); @@ -207,7 +214,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() var repoId = _orgRepoContext.RepositoryContext.RepositoryId; var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(false, new[] { "new" }), - new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false), + new BranchProtectionRequiredReviewsUpdate(new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, false, 2), new BranchProtectionPushRestrictionsUpdate(), false); @@ -219,6 +226,7 @@ public async Task UpdatesBranchProtectionForOrgRepoWithRepositoryId() Assert.Null(protection.RequiredPullRequestReviews.DismissalRestrictions); Assert.False(protection.RequiredPullRequestReviews.DismissStaleReviews); Assert.False(protection.RequiredPullRequestReviews.RequireCodeOwnerReviews); + Assert.Equal(2, protection.RequiredPullRequestReviews.RequiredApprovingReviewCount); Assert.Empty(protection.Restrictions.Teams); Assert.Empty(protection.Restrictions.Users); @@ -391,26 +399,28 @@ public async Task UpdatesReviewEnforcement() { var repoOwner = _userRepoContext.RepositoryOwner; var repoName = _userRepoContext.RepositoryName; - var update = new BranchProtectionRequiredReviewsUpdate(false, true); + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] public async Task UpdatesReviewEnforcementWithRepositoryId() { var repoId = _userRepoContext.RepositoryId; - var update = new BranchProtectionRequiredReviewsUpdate(false, true); + var update = new BranchProtectionRequiredReviewsUpdate(false, true, 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.True(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -421,13 +431,15 @@ public async Task UpdatesReviewEnforcementForOrgRepo() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -437,13 +449,15 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithRepositoryId() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(false), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); Assert.Null(requiredReviews.DismissalRestrictions); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -454,7 +468,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnly() var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); @@ -471,7 +486,8 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); @@ -479,6 +495,7 @@ public async Task UpdatesReviewEnforcementForOrgRepoWithAdminOnlyWithRepositoryI Assert.Empty(requiredReviews.DismissalRestrictions.Users); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } public void Dispose() diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index 28f0415366..40a5602a6f 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -33,7 +33,7 @@ public async Task RequestsTheCorrectUrl() await client.GetAll("owner", "name"); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions); + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json", Args.ApiOptions); } [Fact] @@ -45,7 +45,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryId() await client.GetAll(1); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions); + .GetAll(Arg.Is(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json", Args.ApiOptions); } [Fact] @@ -64,7 +64,7 @@ public async Task RequestsTheCorrectUrlWithApiOptions() await client.GetAll("owner", "name", options); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", options); + .GetAll(Arg.Is(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json", options); } [Fact] @@ -83,7 +83,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryIdWithApiOptions() await client.GetAll(1, options); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", options); + .GetAll(Arg.Is(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json", options); } [Fact] @@ -118,7 +118,7 @@ public async Task RequestsTheCorrectUrl() await client.Get("owner", "repo", "branch"); connection.Received() - .Get(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json"); + .Get(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"); } [Fact] @@ -130,7 +130,7 @@ public async Task RequestsTheCorrectUrlWithRepositoryId() await client.Get(1, "branch"); connection.Received() - .Get(Arg.Is(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.loki-preview+json"); + .Get(Arg.Is(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"); } [Fact] @@ -157,7 +157,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetBranchProtection("owner", "repo", "branch"); @@ -170,7 +170,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetBranchProtection(1, "branch"); @@ -206,7 +206,7 @@ public void RequestsTheCorrectUrl() var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateBranchProtection("owner", "repo", "branch", update); @@ -221,7 +221,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" })); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateBranchProtection(1, "branch", update); @@ -259,7 +259,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteBranchProtection("owner", "repo", "branch"); @@ -272,7 +272,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteBranchProtection(1, "branch"); @@ -306,7 +306,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetRequiredStatusChecks("owner", "repo", "branch"); @@ -319,7 +319,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetRequiredStatusChecks(1, "branch"); @@ -354,7 +354,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecks("owner", "repo", "branch", update); @@ -368,7 +368,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "test" }); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecks(1, "branch", update); @@ -405,7 +405,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecks("owner", "repo", "branch"); @@ -418,7 +418,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecks(1, "branch"); @@ -452,7 +452,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAllRequiredStatusChecksContexts("owner", "repo", "branch"); @@ -465,7 +465,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAllRequiredStatusChecksContexts(1, "branch"); @@ -500,7 +500,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecksContexts("owner", "repo", "branch", update); @@ -514,7 +514,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateRequiredStatusChecksContexts(1, "branch", update); @@ -552,7 +552,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newContexts = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddRequiredStatusChecksContexts("owner", "repo", "branch", newContexts); @@ -566,7 +566,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newContexts = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddRequiredStatusChecksContexts(1, "branch", newContexts); @@ -604,7 +604,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var contextsToRemove = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecksContexts("owner", "repo", "branch", contextsToRemove); @@ -618,7 +618,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var contextsToRemove = new List() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteRequiredStatusChecksContexts(1, "branch", contextsToRemove); @@ -655,7 +655,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetReviewEnforcement("owner", "repo", "branch"); @@ -668,7 +668,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetReviewEnforcement(1, "branch"); @@ -702,8 +702,8 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateReviewEnforcement("owner", "repo", "branch", update); @@ -716,8 +716,8 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateReviewEnforcement(1, "branch", update); @@ -730,7 +730,7 @@ public async Task EnsuresNonNullArguments() { var client = new RepositoryBranchesClient(Substitute.For()); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); await Assert.ThrowsAsync(() => client.UpdateReviewEnforcement(null, "repo", "branch", update)); await Assert.ThrowsAsync(() => client.UpdateReviewEnforcement("owner", null, "branch", update)); @@ -755,7 +755,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.RemoveReviewEnforcement("owner", "repo", "branch"); @@ -768,7 +768,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.RemoveReviewEnforcement(1, "branch"); @@ -802,7 +802,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAdminEnforcement("owner", "repo", "branch"); @@ -815,7 +815,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAdminEnforcement(1, "branch"); @@ -849,7 +849,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddAdminEnforcement("owner", "repo", "branch"); @@ -862,7 +862,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddAdminEnforcement(1, "branch"); @@ -896,7 +896,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.RemoveAdminEnforcement("owner", "repo", "branch"); @@ -909,7 +909,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.RemoveAdminEnforcement(1, "branch"); @@ -943,7 +943,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetProtectedBranchRestrictions("owner", "repo", "branch"); @@ -956,7 +956,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetProtectedBranchRestrictions(1, "branch"); @@ -990,7 +990,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchRestrictions("owner", "repo", "branch"); @@ -1003,7 +1003,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchRestrictions(1, "branch"); @@ -1044,7 +1044,7 @@ public void RequestsTheCorrectUrl() .Get>( Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), null, - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1059,7 +1059,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() .Get>( Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), null, - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1097,7 +1097,7 @@ public void RequestsTheCorrectUrl() Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), Arg.Any>(), null, - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1114,7 +1114,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), Arg.Any>(), null, - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1154,7 +1154,7 @@ public void RequestsTheCorrectUrl() .Post>( Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), Arg.Any>(), - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1170,7 +1170,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() .Post>( Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), Arg.Any>(), - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1210,7 +1210,7 @@ public void RequestsTheCorrectUrl() .Delete>( Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"), Arg.Any(), - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1226,7 +1226,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() .Delete>( Arg.Is(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"), Arg.Any>(), - "application/vnd.github.loki-preview+json,application/vnd.github.hellcat-preview+json"); + "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.hellcat-preview+json"); } [Fact] @@ -1258,7 +1258,7 @@ public void RequestsTheCorrectUrl() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAllProtectedBranchUserRestrictions("owner", "repo", "branch"); @@ -1271,7 +1271,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.GetAllProtectedBranchUserRestrictions(1, "branch"); @@ -1306,7 +1306,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); @@ -1320,7 +1320,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.UpdateProtectedBranchUserRestrictions(1, "branch", newUsers); @@ -1358,7 +1358,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddProtectedBranchUserRestrictions("owner", "repo", "branch", newUsers); @@ -1372,7 +1372,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var newUsers = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.AddProtectedBranchUserRestrictions(1, "branch", newUsers); @@ -1410,7 +1410,7 @@ public void RequestsTheCorrectUrl() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var usersToRemove = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchUserRestrictions("owner", "repo", "branch", usersToRemove); @@ -1424,7 +1424,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var usersToRemove = new BranchProtectionUserCollection() { "test" }; - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; + const string previewAcceptsHeader = "application/vnd.github.loki-preview+json,application/vnd.github.luke-cage-preview+json"; client.DeleteProtectedBranchUserRestrictions(1, "branch", usersToRemove); diff --git a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs index 32fab8fbf9..0001c8c425 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -674,7 +674,7 @@ public void RequestsTheCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); client.UpdateReviewEnforcement("owner", "repo", "branch", update); @@ -686,7 +686,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableRepositoryBranchesClient(gitHubClient); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); client.UpdateReviewEnforcement(1, "branch", update); @@ -697,7 +697,7 @@ public void RequestsTheCorrectUrlWithRepositoryId() public async Task EnsuresNonNullArguments() { var client = new ObservableRepositoryBranchesClient(Substitute.For()); - var update = new BranchProtectionRequiredReviewsUpdate(false, false); + var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2); Assert.Throws(() => client.UpdateReviewEnforcement(null, "repo", "branch", update)); Assert.Throws(() => client.UpdateReviewEnforcement("owner", null, "branch", update)); diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index b0e50d8246..46e1bf6883 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -13,6 +13,8 @@ namespace Octokit /// public class RepositoryBranchesClient : ApiClient, IRepositoryBranchesClient { + private string protectedBranchesPreviewHeaders = AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview); + /// /// Initializes a new GitHub Repository Branches API client. /// @@ -66,7 +68,7 @@ public Task> GetAll(string owner, string name, ApiOptions Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesApiPreview, options); + return ApiConnection.GetAll(ApiUrls.RepoBranches(owner, name), null, protectedBranchesPreviewHeaders, options); } /// @@ -81,7 +83,7 @@ public Task> GetAll(long repositoryId, ApiOptions options) { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.RepoBranches(repositoryId), null, AcceptHeaders.ProtectedBranchesApiPreview, options); + return ApiConnection.GetAll(ApiUrls.RepoBranches(repositoryId), null, protectedBranchesPreviewHeaders, options); } /// @@ -99,7 +101,7 @@ public Task Get(string owner, string name, string branch) Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoBranch(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoBranch(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -114,7 +116,7 @@ public Task Get(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoBranch(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoBranch(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -132,7 +134,7 @@ public Task GetBranchProtection(string owner, string n Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoBranchProtection(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoBranchProtection(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -147,7 +149,7 @@ public Task GetBranchProtection(long repositoryId, str { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoBranchProtection(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoBranchProtection(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -167,7 +169,7 @@ public Task UpdateBranchProtection(string owner, strin Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, protectedBranchesPreviewHeaders); } /// @@ -184,7 +186,7 @@ public Task UpdateBranchProtection(long repositoryId, Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Put(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, protectedBranchesPreviewHeaders); } /// @@ -205,7 +207,7 @@ public async Task DeleteBranchProtection(string owner, string name, string var endpoint = ApiUrls.RepoBranchProtection(owner, name, branch); try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -229,7 +231,7 @@ public async Task DeleteBranchProtection(long repositoryId, string branch) var endpoint = ApiUrls.RepoBranchProtection(repositoryId, branch); try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -253,7 +255,7 @@ public Task GetRequiredStatusChecks(string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -268,7 +270,7 @@ public Task GetRequiredStatusChecks(long r { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -288,7 +290,7 @@ public Task UpdateRequiredStatusChecks(str Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Patch(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update, protectedBranchesPreviewHeaders); } /// @@ -305,7 +307,7 @@ public Task UpdateRequiredStatusChecks(lon Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Patch(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update, protectedBranchesPreviewHeaders); } /// @@ -327,7 +329,7 @@ public async Task DeleteRequiredStatusChecks(string owner, string name, st try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -352,7 +354,7 @@ public async Task DeleteRequiredStatusChecks(long repositoryId, string bra try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -376,7 +378,7 @@ public Task> GetAllRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -391,7 +393,7 @@ public Task> GetAllRequiredStatusChecksContexts(long repos { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -411,7 +413,7 @@ public Task> UpdateRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null, protectedBranchesPreviewHeaders); } /// @@ -428,7 +430,7 @@ public Task> UpdateRequiredStatusChecksContexts(long repos Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null, protectedBranchesPreviewHeaders); } /// @@ -448,7 +450,7 @@ public Task> AddRequiredStatusChecksContexts(string owner, Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Post>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, protectedBranchesPreviewHeaders); } /// @@ -465,7 +467,7 @@ public Task> AddRequiredStatusChecksContexts(long reposito Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Post>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, protectedBranchesPreviewHeaders); } /// @@ -485,7 +487,7 @@ public Task> DeleteRequiredStatusChecksContexts(string own Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Delete>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Delete>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, protectedBranchesPreviewHeaders); } /// @@ -502,7 +504,7 @@ public Task> DeleteRequiredStatusChecksContexts(long repos Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(contexts, nameof(contexts)); - return ApiConnection.Delete>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Delete>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, protectedBranchesPreviewHeaders); } /// @@ -520,7 +522,7 @@ public Task GetReviewEnforcement(string owner, Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -535,7 +537,7 @@ public Task GetReviewEnforcement(long repositor { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -555,7 +557,7 @@ public Task UpdateReviewEnforcement(string owne Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Patch(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update, protectedBranchesPreviewHeaders); } /// @@ -572,7 +574,7 @@ public Task UpdateReviewEnforcement(long reposi Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(update, nameof(update)); - return ApiConnection.Patch(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Patch(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update, protectedBranchesPreviewHeaders); } /// @@ -594,7 +596,7 @@ public async Task RemoveReviewEnforcement(string owner, string name, strin try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -619,7 +621,7 @@ public async Task RemoveReviewEnforcement(long repositoryId, string branch try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -643,7 +645,7 @@ public Task GetAdminEnforcement(string owner, string name, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -658,7 +660,7 @@ public Task GetAdminEnforcement(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -676,7 +678,7 @@ public Task AddAdminEnforcement(string owner, string name, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Post(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object(), AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object(), protectedBranchesPreviewHeaders); } /// @@ -691,7 +693,7 @@ public Task AddAdminEnforcement(long repositoryId, string branch) { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Post(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object(), AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object(), protectedBranchesPreviewHeaders); } /// @@ -713,7 +715,7 @@ public async Task RemoveAdminEnforcement(string owner, string name, string try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -738,7 +740,7 @@ public async Task RemoveAdminEnforcement(long repositoryId, string branch) try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -762,7 +764,7 @@ public Task GetProtectedBranchRestrictions(str Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoRestrictions(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoRestrictions(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -777,7 +779,7 @@ public Task GetProtectedBranchRestrictions(lon { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get(ApiUrls.RepoRestrictions(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get(ApiUrls.RepoRestrictions(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -799,7 +801,7 @@ public async Task DeleteProtectedBranchRestrictions(string owner, string n try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -824,7 +826,7 @@ public async Task DeleteProtectedBranchRestrictions(long repositoryId, str try { - var httpStatusCode = await Connection.Delete(endpoint, null, AcceptHeaders.ProtectedBranchesApiPreview).ConfigureAwait(false); + var httpStatusCode = await Connection.Delete(endpoint, null, protectedBranchesPreviewHeaders).ConfigureAwait(false); return httpStatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) @@ -848,7 +850,7 @@ public Task> GetAllProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Get>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -863,7 +865,7 @@ public Task> GetAllProtectedBranchTeamRestrictions(long repo { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Get>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -883,7 +885,7 @@ public Task> UpdateProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -900,7 +902,7 @@ public Task> UpdateProtectedBranchTeamRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -920,7 +922,7 @@ public Task> AddProtectedBranchTeamRestrictions(string owner Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Post>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Post>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -937,7 +939,7 @@ public Task> AddProtectedBranchTeamRestrictions(long reposit Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Post>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Post>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -957,7 +959,7 @@ public Task> DeleteProtectedBranchTeamRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Delete>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Delete>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -974,7 +976,7 @@ public Task> DeleteProtectedBranchTeamRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(teams, nameof(teams)); - return ApiConnection.Delete>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview)); + return ApiConnection.Delete>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview)); } /// @@ -992,7 +994,7 @@ public Task> GetAllProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null, protectedBranchesPreviewHeaders); } /// @@ -1007,7 +1009,7 @@ public Task> GetAllProtectedBranchUserRestrictions(long repo { Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); - return ApiConnection.Get>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Get>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null, protectedBranchesPreviewHeaders); } /// @@ -1027,7 +1029,7 @@ public Task> UpdateProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null, protectedBranchesPreviewHeaders); } /// @@ -1044,7 +1046,7 @@ public Task> UpdateProtectedBranchUserRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Put>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null, protectedBranchesPreviewHeaders); } /// @@ -1064,7 +1066,7 @@ public Task> AddProtectedBranchUserRestrictions(string owner Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Post>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, protectedBranchesPreviewHeaders); } /// @@ -1081,7 +1083,7 @@ public Task> AddProtectedBranchUserRestrictions(long reposit Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Post>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Post>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, protectedBranchesPreviewHeaders); } /// @@ -1101,7 +1103,7 @@ public Task> DeleteProtectedBranchUserRestrictions(string ow Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Delete>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Delete>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, protectedBranchesPreviewHeaders); } /// @@ -1118,7 +1120,7 @@ public Task> DeleteProtectedBranchUserRestrictions(long repo Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch)); Ensure.ArgumentNotNull(users, nameof(users)); - return ApiConnection.Delete>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesApiPreview); + return ApiConnection.Delete>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, protectedBranchesPreviewHeaders); } } } diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index 964982f9de..085ff4f3af 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -65,6 +65,8 @@ public static class AcceptHeaders public const string ChecksApiPreview = "application/vnd.github.antiope-preview+json"; + public const string ProtectedBranchesRequiredApprovingApiPreview = "application/vnd.github.luke-cage-preview+json"; + /// /// Combines multiple preview headers. GitHub API supports Accept header with multiple /// values separated by comma. diff --git a/Octokit/Models/Request/BranchProtectionUpdate.cs b/Octokit/Models/Request/BranchProtectionUpdate.cs index eda3c0a813..227730c3da 100644 --- a/Octokit/Models/Request/BranchProtectionUpdate.cs +++ b/Octokit/Models/Request/BranchProtectionUpdate.cs @@ -184,7 +184,7 @@ public BranchProtectionPushRestrictionsUpdate() /// /// Specify teams (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail /// - /// Teams allowed to push to this branch + /// List of Team slugs allowed to push to this branch public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNull(teams, nameof(teams)); @@ -196,7 +196,7 @@ public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection tea /// /// Specify people (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail /// - /// Users allowed to push to this branch + /// List of User logins allowed to push to this branch public BranchProtectionPushRestrictionsUpdate(BranchProtectionUserCollection users) { Ensure.ArgumentNotNull(users, nameof(users)); @@ -208,8 +208,8 @@ public BranchProtectionPushRestrictionsUpdate(BranchProtectionUserCollection use /// /// Specify teams and/or people (in addition to Administrators) allowed to push to this branch. Required status checks will still prevent these people from merging if the checks fail /// - /// Teams allowed to push to this branch - /// Users allowed to push to this branch + /// List of Team slugs allowed to push to this branch + /// List of User logins allowed to push to this branch public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams, BranchProtectionUserCollection users) { Ensure.ArgumentNotNull(teams, nameof(teams)); @@ -220,12 +220,12 @@ public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection tea } /// - /// Teams allowed to push to this branch + /// List of Team slugs allowed to push to this branch /// public BranchProtectionTeamCollection Teams { get; private set; } /// - /// Users allowed to push to this branch + /// List of User logins allowed to push to this branch /// public BranchProtectionUserCollection Users { get; private set; } @@ -288,10 +288,12 @@ public class BranchProtectionRequiredReviewsUpdate /// /// Dismiss approved reviews automatically when a new commit is pushed. /// Blocks merge until code owners have reviewed. - public BranchProtectionRequiredReviewsUpdate(bool dismissStaleReviews, bool requireCodeOwnerReviews) + /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. + public BranchProtectionRequiredReviewsUpdate(bool dismissStaleReviews, bool requireCodeOwnerReviews, int requiredApprovingReviewCount) { DismissStaleReviews = dismissStaleReviews; RequireCodeOwnerReviews = requireCodeOwnerReviews; + RequiredApprovingReviewCount = requiredApprovingReviewCount; } /// @@ -300,13 +302,15 @@ public BranchProtectionRequiredReviewsUpdate(bool dismissStaleReviews, bool requ /// Specify which users and teams can dismiss pull request reviews (applies only to Organization owned repositories). /// Dismiss approved reviews automatically when a new commit is pushed. /// Blocks merge until code owners have reviewed. - public BranchProtectionRequiredReviewsUpdate(BranchProtectionRequiredReviewsDismissalRestrictionsUpdate dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews) + /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. + public BranchProtectionRequiredReviewsUpdate(BranchProtectionRequiredReviewsDismissalRestrictionsUpdate dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews, int requiredApprovingReviewCount) { Ensure.ArgumentNotNull(dismissalRestrictions, nameof(dismissalRestrictions)); DismissalRestrictions = dismissalRestrictions; DismissStaleReviews = dismissStaleReviews; RequireCodeOwnerReviews = requireCodeOwnerReviews; + RequiredApprovingReviewCount = requiredApprovingReviewCount; } /// @@ -324,14 +328,20 @@ public BranchProtectionRequiredReviewsUpdate(BranchProtectionRequiredReviewsDism /// public bool RequireCodeOwnerReviews { get; protected set; } + /// + /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. + /// + public int RequiredApprovingReviewCount { get; protected set; } + internal string DebuggerDisplay { get { - return string.Format(CultureInfo.InvariantCulture, "DismissalRestrictions: {0} DismissStaleReviews: {1} RequireCodeOwnerReviews: {2}", + return string.Format(CultureInfo.InvariantCulture, "DismissalRestrictions: {0} DismissStaleReviews: {1} RequireCodeOwnerReviews: {2} RequiredApprovingReviewCount: {3}", DismissalRestrictions?.DebuggerDisplay ?? "disabled", DismissStaleReviews, - RequireCodeOwnerReviews); + RequireCodeOwnerReviews, + RequiredApprovingReviewCount); } } } @@ -365,7 +375,7 @@ public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(bool enabled) /// /// Restrict dismissing reviews to the specified teams (in addition to Administrators). /// - /// Teams allowed to dismiss reviews + /// List of Team slugs allowed to dismiss reviews public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionTeamCollection teams) { Ensure.ArgumentNotNull(teams, nameof(teams)); @@ -377,7 +387,7 @@ public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtecti /// /// Restrict dismissing reviews to the specified people (in addition to Administrators). /// - /// Users allowed to dismiss reviews + /// List of User logins allowed to dismiss reviews public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionUserCollection users) { Ensure.ArgumentNotNull(users, nameof(users)); @@ -389,8 +399,8 @@ public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtecti /// /// Restrict dismissing reviews to the specified teams and people (in addition to Administrators). /// - /// Teams allowed to dismiss reviews - /// Users allowed to dismiss reviews + /// List of Team slugs allowed to dismiss reviews + /// List of User logins allowed to dismiss reviews public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionTeamCollection teams, BranchProtectionUserCollection users) { Ensure.ArgumentNotNull(teams, nameof(teams)); @@ -401,12 +411,12 @@ public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtecti } /// - /// Teams allowed to dismiss reviews + /// List of Team slugs allowed to dismiss reviews /// public BranchProtectionTeamCollection Teams { get; private set; } /// - /// Users allowed to dismiss reviews + /// List of User logins allowed to dismiss reviews /// public BranchProtectionUserCollection Users { get; private set; } diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index 0b823581ad..e73e864507 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -1,10 +1,8 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.Linq; -using Octokit.Internal; namespace Octokit { @@ -165,11 +163,12 @@ public class BranchProtectionRequiredReviews { public BranchProtectionRequiredReviews() { } - public BranchProtectionRequiredReviews(BranchProtectionRequiredReviewsDismissalRestrictions dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews) + public BranchProtectionRequiredReviews(BranchProtectionRequiredReviewsDismissalRestrictions dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews, int requiredApprovingReviewCount) { DismissalRestrictions = dismissalRestrictions; DismissStaleReviews = dismissStaleReviews; RequireCodeOwnerReviews = requireCodeOwnerReviews; + RequiredApprovingReviewCount = requiredApprovingReviewCount; } /// @@ -187,14 +186,20 @@ public BranchProtectionRequiredReviews(BranchProtectionRequiredReviewsDismissalR /// public bool RequireCodeOwnerReviews { get; protected set; } + /// + /// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. + /// + public int RequiredApprovingReviewCount { get; protected set; } + internal string DebuggerDisplay { get { - return string.Format(CultureInfo.InvariantCulture, "DismissalRestrictions: {0} DismissStaleReviews: {1} RequireCodeOwnerReviews: {2}", + return string.Format(CultureInfo.InvariantCulture, "DismissalRestrictions: {0} DismissStaleReviews: {1} RequireCodeOwnerReviews: {2} RequiredApprovingReviewCount: {3}", DismissalRestrictions?.DebuggerDisplay ?? "disabled", DismissStaleReviews, - RequireCodeOwnerReviews); + RequireCodeOwnerReviews, + RequiredApprovingReviewCount); } } }