add RequiredApprovingReview preview functionality to branch protection calls (#1912)

This commit is contained in:
Ryan Gribble
2019-01-30 21:20:50 +10:00
committed by GitHub
parent 64cecbb264
commit cf442499ff
9 changed files with 213 additions and 163 deletions

View File

@@ -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()

View File

@@ -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);

View File

@@ -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()

View File

@@ -33,7 +33,7 @@ namespace Octokit.Tests.Clients
await client.GetAll("owner", "name");
connection.Received()
.GetAll<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions);
.GetAll<Branch>(Arg.Is<Uri>(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<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", Args.ApiOptions);
.GetAll<Branch>(Arg.Is<Uri>(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<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/name/branches"), null, "application/vnd.github.loki-preview+json", options);
.GetAll<Branch>(Arg.Is<Uri>(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<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches"), null, "application/vnd.github.loki-preview+json", options);
.GetAll<Branch>(Arg.Is<Uri>(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<Branch>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch"), null, "application/vnd.github.loki-preview+json");
.Get<Branch>(Arg.Is<Uri>(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<Branch>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch"), null, "application/vnd.github.loki-preview+json");
.Get<Branch>(Arg.Is<Uri>(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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var update = new List<string>() { "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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var update = new List<string>() { "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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var newContexts = new List<string>() { "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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var newContexts = new List<string>() { "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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var contextsToRemove = new List<string>() { "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<IApiConnection>();
var client = new RepositoryBranchesClient(connection);
var contextsToRemove = new List<string>() { "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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>());
var update = new BranchProtectionRequiredReviewsUpdate(false, false);
var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2);
await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateReviewEnforcement(null, "repo", "branch", update));
await Assert.ThrowsAsync<ArgumentNullException>(() => client.UpdateReviewEnforcement("owner", null, "branch", update));
@@ -755,7 +755,7 @@ namespace Octokit.Tests.Clients
{
var connection = Substitute.For<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IReadOnlyList<Team>>(
Arg.Is<Uri>(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<IReadOnlyList<Team>>(
Arg.Is<Uri>(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<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
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<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
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<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
"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<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
"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<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/branches/branch/protection/restrictions/teams"),
Arg.Any<BranchProtectionTeamCollection>(),
"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<IReadOnlyList<Team>>(
Arg.Is<Uri>(u => u.ToString() == "repositories/1/branches/branch/protection/restrictions/teams"),
Arg.Any<IReadOnlyList<string>>(),
"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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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<IApiConnection>();
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);

View File

@@ -674,7 +674,7 @@ namespace Octokit.Tests.Reactive
{
var gitHubClient = Substitute.For<IGitHubClient>();
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<IGitHubClient>();
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<IGitHubClient>());
var update = new BranchProtectionRequiredReviewsUpdate(false, false);
var update = new BranchProtectionRequiredReviewsUpdate(false, false, 2);
Assert.Throws<ArgumentNullException>(() => client.UpdateReviewEnforcement(null, "repo", "branch", update));
Assert.Throws<ArgumentNullException>(() => client.UpdateReviewEnforcement("owner", null, "branch", update));

View File

@@ -13,6 +13,8 @@ namespace Octokit
/// </remarks>
public class RepositoryBranchesClient : ApiClient, IRepositoryBranchesClient
{
private string protectedBranchesPreviewHeaders = AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.ProtectedBranchesRequiredApprovingApiPreview);
/// <summary>
/// Initializes a new GitHub Repository Branches API client.
/// </summary>
@@ -66,7 +68,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, AcceptHeaders.ProtectedBranchesApiPreview, options);
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(owner, name), null, protectedBranchesPreviewHeaders, options);
}
/// <summary>
@@ -81,7 +83,7 @@ namespace Octokit
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(repositoryId), null, AcceptHeaders.ProtectedBranchesApiPreview, options);
return ApiConnection.GetAll<Branch>(ApiUrls.RepoBranches(repositoryId), null, protectedBranchesPreviewHeaders, options);
}
/// <summary>
@@ -99,7 +101,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -114,7 +116,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<Branch>(ApiUrls.RepoBranch(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -132,7 +134,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -147,7 +149,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -167,7 +169,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(owner, name, branch), update, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -184,7 +186,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<BranchProtectionSettings>(ApiUrls.RepoBranchProtection(repositoryId, branch), update, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -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<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -268,7 +270,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -288,7 +290,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(owner, name, branch), update, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -305,7 +307,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Patch<BranchProtectionRequiredStatusChecks>(ApiUrls.RepoRequiredStatusChecks(repositoryId, branch), update, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -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<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -391,7 +393,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -411,7 +413,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -428,7 +430,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -448,7 +450,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -465,7 +467,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -485,7 +487,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(owner, name, branch), contexts, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -502,7 +504,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(contexts, nameof(contexts));
return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Delete<IReadOnlyList<string>>(ApiUrls.RepoRequiredStatusChecksContexts(repositoryId, branch), contexts, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -520,7 +522,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -535,7 +537,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -555,7 +557,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(owner, name, branch), update, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -572,7 +574,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(update, nameof(update));
return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Patch<BranchProtectionRequiredReviews>(ApiUrls.RepoProtectedBranchReviewEnforcement(repositoryId, branch), update, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -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<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -658,7 +660,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -676,7 +678,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object(), AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(owner, name, branch), new object(), protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -691,7 +693,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object(), AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<EnforceAdmins>(ApiUrls.RepoProtectedBranchAdminEnforcement(repositoryId, branch), new object(), protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -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<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -777,7 +779,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<BranchProtectionPushRestrictions>(ApiUrls.RepoRestrictions(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -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<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -863,7 +865,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Get<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -883,7 +885,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -900,7 +902,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Put<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, null, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -920,7 +922,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -937,7 +939,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Post<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -957,7 +959,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(owner, name, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -974,7 +976,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(teams, nameof(teams));
return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(AcceptHeaders.ProtectedBranchesApiPreview, AcceptHeaders.NestedTeamsPreview));
return ApiConnection.Delete<IReadOnlyList<Team>>(ApiUrls.RepoRestrictionsTeams(repositoryId, branch), teams, AcceptHeaders.Concat(protectedBranchesPreviewHeaders, AcceptHeaders.NestedTeamsPreview));
}
/// <summary>
@@ -992,7 +994,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1007,7 +1009,7 @@ namespace Octokit
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Get<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1027,7 +1029,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1044,7 +1046,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Put<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, null, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1064,7 +1066,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1081,7 +1083,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Post<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1101,7 +1103,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(owner, name, branch), users, protectedBranchesPreviewHeaders);
}
/// <summary>
@@ -1118,7 +1120,7 @@ namespace Octokit
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
Ensure.ArgumentNotNull(users, nameof(users));
return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, AcceptHeaders.ProtectedBranchesApiPreview);
return ApiConnection.Delete<IReadOnlyList<User>>(ApiUrls.RepoRestrictionsUsers(repositoryId, branch), users, protectedBranchesPreviewHeaders);
}
}
}

View File

@@ -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";
/// <summary>
/// Combines multiple preview headers. GitHub API supports Accept header with multiple
/// values separated by comma.

View File

@@ -184,7 +184,7 @@ namespace Octokit
/// <summary>
/// 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
/// </summary>
/// <param name="teams">Teams allowed to push to this branch</param>
/// <param name="teams">List of Team slugs allowed to push to this branch</param>
public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams)
{
Ensure.ArgumentNotNull(teams, nameof(teams));
@@ -196,7 +196,7 @@ namespace Octokit
/// <summary>
/// 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
/// </summary>
/// <param name="users">Users allowed to push to this branch</param>
/// <param name="users">List of User logins allowed to push to this branch</param>
public BranchProtectionPushRestrictionsUpdate(BranchProtectionUserCollection users)
{
Ensure.ArgumentNotNull(users, nameof(users));
@@ -208,8 +208,8 @@ namespace Octokit
/// <summary>
/// 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
/// </summary>
/// <param name="teams">Teams allowed to push to this branch</param>
/// <param name="users">Users allowed to push to this branch</param>
/// <param name="teams">List of Team slugs allowed to push to this branch</param>
/// <param name="users">List of User logins allowed to push to this branch</param>
public BranchProtectionPushRestrictionsUpdate(BranchProtectionTeamCollection teams, BranchProtectionUserCollection users)
{
Ensure.ArgumentNotNull(teams, nameof(teams));
@@ -220,12 +220,12 @@ namespace Octokit
}
/// <summary>
/// Teams allowed to push to this branch
/// List of Team slugs allowed to push to this branch
/// </summary>
public BranchProtectionTeamCollection Teams { get; private set; }
/// <summary>
/// Users allowed to push to this branch
/// List of User logins allowed to push to this branch
/// </summary>
public BranchProtectionUserCollection Users { get; private set; }
@@ -288,10 +288,12 @@ namespace Octokit
/// </summary>
/// <param name="dismissStaleReviews">Dismiss approved reviews automatically when a new commit is pushed.</param>
/// <param name="requireCodeOwnerReviews">Blocks merge until code owners have reviewed.</param>
public BranchProtectionRequiredReviewsUpdate(bool dismissStaleReviews, bool requireCodeOwnerReviews)
/// <param name="requiredApprovingReviewCount">Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6.</param>
public BranchProtectionRequiredReviewsUpdate(bool dismissStaleReviews, bool requireCodeOwnerReviews, int requiredApprovingReviewCount)
{
DismissStaleReviews = dismissStaleReviews;
RequireCodeOwnerReviews = requireCodeOwnerReviews;
RequiredApprovingReviewCount = requiredApprovingReviewCount;
}
/// <summary>
@@ -300,13 +302,15 @@ namespace Octokit
/// <param name="dismissalRestrictions">Specify which users and teams can dismiss pull request reviews (applies only to Organization owned repositories).</param>
/// <param name="dismissStaleReviews">Dismiss approved reviews automatically when a new commit is pushed.</param>
/// <param name="requireCodeOwnerReviews">Blocks merge until code owners have reviewed.</param>
public BranchProtectionRequiredReviewsUpdate(BranchProtectionRequiredReviewsDismissalRestrictionsUpdate dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews)
/// <param name="requiredApprovingReviewCount">Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6.</param>
public BranchProtectionRequiredReviewsUpdate(BranchProtectionRequiredReviewsDismissalRestrictionsUpdate dismissalRestrictions, bool dismissStaleReviews, bool requireCodeOwnerReviews, int requiredApprovingReviewCount)
{
Ensure.ArgumentNotNull(dismissalRestrictions, nameof(dismissalRestrictions));
DismissalRestrictions = dismissalRestrictions;
DismissStaleReviews = dismissStaleReviews;
RequireCodeOwnerReviews = requireCodeOwnerReviews;
RequiredApprovingReviewCount = requiredApprovingReviewCount;
}
/// <summary>
@@ -324,14 +328,20 @@ namespace Octokit
/// </summary>
public bool RequireCodeOwnerReviews { get; protected set; }
/// <summary>
/// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6.
/// </summary>
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
/// <summary>
/// Restrict dismissing reviews to the specified teams (in addition to Administrators).
/// </summary>
/// <param name="teams">Teams allowed to dismiss reviews</param>
/// <param name="teams">List of Team slugs allowed to dismiss reviews</param>
public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionTeamCollection teams)
{
Ensure.ArgumentNotNull(teams, nameof(teams));
@@ -377,7 +387,7 @@ namespace Octokit
/// <summary>
/// Restrict dismissing reviews to the specified people (in addition to Administrators).
/// </summary>
/// <param name="users">Users allowed to dismiss reviews</param>
/// <param name="users">List of User logins allowed to dismiss reviews</param>
public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionUserCollection users)
{
Ensure.ArgumentNotNull(users, nameof(users));
@@ -389,8 +399,8 @@ namespace Octokit
/// <summary>
/// Restrict dismissing reviews to the specified teams and people (in addition to Administrators).
/// </summary>
/// <param name="teams">Teams allowed to dismiss reviews</param>
/// <param name="users">Users allowed to dismiss reviews</param>
/// <param name="teams">List of Team slugs allowed to dismiss reviews</param>
/// <param name="users">List of User logins allowed to dismiss reviews</param>
public BranchProtectionRequiredReviewsDismissalRestrictionsUpdate(BranchProtectionTeamCollection teams, BranchProtectionUserCollection users)
{
Ensure.ArgumentNotNull(teams, nameof(teams));
@@ -401,12 +411,12 @@ namespace Octokit
}
/// <summary>
/// Teams allowed to dismiss reviews
/// List of Team slugs allowed to dismiss reviews
/// </summary>
public BranchProtectionTeamCollection Teams { get; private set; }
/// <summary>
/// Users allowed to dismiss reviews
/// List of User logins allowed to dismiss reviews
/// </summary>
public BranchProtectionUserCollection Users { get; private set; }

View File

@@ -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;
}
/// <summary>
@@ -187,14 +186,20 @@ namespace Octokit
/// </summary>
public bool RequireCodeOwnerReviews { get; protected set; }
/// <summary>
/// Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6.
/// </summary>
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);
}
}
}