diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 5c5dba03..cbc465bb 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -318,7 +318,7 @@ public class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests { 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests 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 class RepositoryBranchesClientTests Assert.Empty(requiredReviews.DismissalRestrictions.Users); Assert.False(requiredReviews.DismissStaleReviews); Assert.False(requiredReviews.RequireCodeOwnerReviews); + Assert.Equal(2, requiredReviews.RequiredApprovingReviewCount); } [IntegrationTest] @@ -953,7 +965,8 @@ public class RepositoryBranchesClientTests var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); @@ -961,6 +974,7 @@ public class RepositoryBranchesClientTests 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 7322913b..8c36d503 100644 --- a/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs +++ b/Octokit.Tests.Integration/Helpers/OrganizationRepositoryWithTeamContext.cs @@ -32,7 +32,7 @@ namespace Octokit.Tests.Integration.Helpers // 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 @@ namespace Octokit.Tests.Integration.Helpers // 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 db4ea1b5..8cbac07c 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -38,6 +38,7 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration { 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration 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 @@ namespace Octokit.Tests.Integration var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoOwner, repoName, "master", update); @@ -471,7 +486,8 @@ namespace Octokit.Tests.Integration var update = new BranchProtectionRequiredReviewsUpdate( new BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(true), false, - false); + false, + 2); var requiredReviews = await _client.UpdateReviewEnforcement(repoId, "master", update); @@ -479,6 +495,7 @@ namespace Octokit.Tests.Integration 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 28f04153..40a5602a 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -33,7 +33,7 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients .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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients { 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 @@ namespace Octokit.Tests.Clients 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 32fab8fb..0001c8c4 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -674,7 +674,7 @@ namespace Octokit.Tests.Reactive { 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 @@ namespace Octokit.Tests.Reactive { 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 @@ namespace Octokit.Tests.Reactive 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 b0e50d82..46e1bf68 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit { 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 @@ namespace Octokit 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 964982f9..085ff4f3 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -65,6 +65,8 @@ namespace Octokit 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 eda3c0a8..227730c3 100644 --- a/Octokit/Models/Request/BranchProtectionUpdate.cs +++ b/Octokit/Models/Request/BranchProtectionUpdate.cs @@ -184,7 +184,7 @@ namespace Octokit /// /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit } /// - /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit /// 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 @@ namespace Octokit /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit /// /// 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 @@ namespace Octokit } /// - /// 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 0b823581..e73e8645 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 @@ namespace Octokit { 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 @@ namespace Octokit /// 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); } } }