From 2c7d6fbe4241087d53c7f47a02b55f6cf13c136f Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 8 Aug 2016 23:28:20 +1000 Subject: [PATCH] push restrictions only apply to org repos so provide a ctor for the update request that doesnt take a restrictions parameter --- Octokit.Tests/Clients/RepositoryBranchesClientTests.cs | 9 +++------ Octokit/Models/Request/BranchProtectionUpdate.cs | 10 ++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index 8d1192f7..f061ff5c 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -257,8 +257,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" }), - new ProtectedBranchRestrictionsUpdate(null, null)); + new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection("owner", "repo", "branch", update); @@ -273,8 +272,7 @@ namespace Octokit.Tests.Clients var connection = Substitute.For(); var client = new RepositoryBranchesClient(connection); var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" }), - new ProtectedBranchRestrictionsUpdate(null, null)); + new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; client.UpdateBranchProtection(1, "branch", update); @@ -288,8 +286,7 @@ namespace Octokit.Tests.Clients { var client = new RepositoryBranchesClient(Substitute.For()); var update = new BranchProtectionSettingsUpdate( - new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" }), - new ProtectedBranchRestrictionsUpdate(null, null)); + new BranchProtectionRequiredStatusChecksUpdate(true, true, new[] { "test" })); await Assert.ThrowsAsync(() => client.UpdateBranchProtection(null, "repo", "branch", update)); await Assert.ThrowsAsync(() => client.UpdateBranchProtection("owner", null, "branch", update)); diff --git a/Octokit/Models/Request/BranchProtectionUpdate.cs b/Octokit/Models/Request/BranchProtectionUpdate.cs index fc198474..85458621 100644 --- a/Octokit/Models/Request/BranchProtectionUpdate.cs +++ b/Octokit/Models/Request/BranchProtectionUpdate.cs @@ -11,6 +11,16 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class BranchProtectionSettingsUpdate { + /// + /// Create a BranchProtection update request + /// + /// Specifies the requested status check settings + public BranchProtectionSettingsUpdate(BranchProtectionRequiredStatusChecksUpdate requiredStatusChecks) + { + RequiredStatusChecks = requiredStatusChecks; + Restrictions = null; + } + /// /// Create a BranchProtection update request ///