diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs index 5d61bd7b..761ab72b 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs @@ -516,27 +516,6 @@ namespace Octokit.Reactive /// The updated IObservable Edit(long repositoryId, RepositoryUpdate update); - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the ObservableRepositoryBranchesClient methods instead.")] - IObservable EditBranch(string owner, string name, string branch, BranchUpdate update); - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the ObservableRepositoryBranchesClient methods instead.")] - IObservable EditBranch(long repositoryId, string branch, BranchUpdate update); - /// /// A client for GitHub's Repo Collaborators. /// diff --git a/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs index 7f23dbb6..5bf66450 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs @@ -75,25 +75,6 @@ namespace Octokit.Reactive [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] IObservable Get(long repositoryId, string branch); - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other ObservableRepositoryBranchesClient methods instead.")] - IObservable Edit(string owner, string name, string branch, BranchUpdate update); - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other ObservableRepositoryBranchesClient methods instead.")] - IObservable Edit(long repositoryId, string branch, BranchUpdate update); - /// /// Get the branch protection settings for the specified branch /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs index 7d7370df..ef51d0fb 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs @@ -771,41 +771,6 @@ namespace Octokit.Reactive return _client.Edit(repositoryId, update).ToObservable(); } - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the ObservableRepositoryBranchesClient methods instead.")] - public IObservable EditBranch(string owner, string name, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return Branch.Edit(owner, name, branch, update); - } - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the ObservableRepositoryBranchesClient methods instead.")] - public IObservable EditBranch(long repositoryId, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return Branch.Edit(repositoryId, branch, update); - } - /// /// Compare two references in a repository /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs index 3973cda5..b3080a21 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs @@ -116,39 +116,6 @@ namespace Octokit.Reactive return _client.Get(repositoryId, branch).ToObservable(); } - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other ObservableRepositoryBranchesClient methods instead.")] - public IObservable Edit(string owner, string name, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return _client.Edit(owner, name, branch, update).ToObservable(); - } - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other ObservableRepositoryBranchesClient methods instead.")] - public IObservable Edit(long repositoryId, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return _client.Edit(repositoryId, branch, update).ToObservable(); - } - /// /// Get the branch protection settings for the specified branch /// diff --git a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs index dd2bcc1c..4cad33fd 100644 --- a/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoriesClientTests.cs @@ -1478,12 +1478,6 @@ public class RepositoriesClientTests var branches = await github.Repository.GetAllBranches(7528679); Assert.NotEmpty(branches); - - // Ensure Protection attribute is deserialized - foreach (var branch in branches) - { - Assert.NotNull(branch.Protection); - } } [IntegrationTest] @@ -1798,102 +1792,4 @@ public class RepositoriesClientTests Assert.NotEqual(firstPage[4].Name, secondPage[4].Name); } } - - public class TheEditBranchMethod - { - private readonly IRepositoriesClient _fixture; - private readonly RepositoryContext _context; - - public TheEditBranchMethod() - { - var github = Helper.GetAuthenticatedClient(); - _context = github.CreateRepositoryContext("source-repo").Result; - _fixture = github.Repository; - } - - public async Task CreateTheWorld() - { - // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var newBranch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - } - - [IntegrationTest] - public async Task ProtectsBranch() - { - // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2", "check3" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the changes were made - Assert.Equal(branch.Protection.Enabled, true); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Everyone); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 3); - } - - [IntegrationTest] - public async Task RemoveStatusCheckEnforcement() - { - await CreateTheWorld(); - - // Remove status check enforcement - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List { "check1" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the changes were made - Assert.Equal(branch.Protection.Enabled, true); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 1); - } - - [IntegrationTest] - public async Task UnprotectsBranch() - { - await CreateTheWorld(); - - // Unprotect branch - // Deliberately set Enforcement and Contexts to some values (these should be ignored) - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(false, requiredStatusChecks); - - var branch = await _fixture.EditBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.GetBranch(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the branch is unprotected, and enforcement/contexts are cleared - Assert.Equal(branch.Protection.Enabled, false); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 0); - } - } } diff --git a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs index 70846d6f..6b72a8d6 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryBranchesClientTests.cs @@ -20,11 +20,6 @@ public class RepositoryBranchesClientTests Assert.NotEmpty(branches); - foreach (var branch in branches) - { - Assert.NotNull(branch.Protection); - } - Assert.True(branches.First(x => x.Name == "master").Protected); } @@ -37,11 +32,6 @@ public class RepositoryBranchesClientTests Assert.NotEmpty(branches); - foreach (var branch in branches) - { - Assert.NotNull(branch.Protection); - } - Assert.True(branches.First(x => x.Name == "master").Protected); } @@ -189,7 +179,6 @@ public class RepositoryBranchesClientTests Assert.NotNull(branch); Assert.Equal("master", branch.Name); - Assert.NotNull(branch.Protection); Assert.True(branch.Protected); } @@ -204,109 +193,10 @@ public class RepositoryBranchesClientTests Assert.NotNull(branch); Assert.Equal("master", branch.Name); - Assert.NotNull(branch.Protection); Assert.True(branch.Protected); } } - public class TheEditMethod - { - private readonly IRepositoryBranchesClient _fixture; - private readonly RepositoryContext _context; - - public TheEditMethod() - { - var github = Helper.GetAuthenticatedClient(); - _context = github.CreateRepositoryContext("source-repo").Result; - _fixture = github.Repository.Branch; - } - - public async Task CreateTheWorld() - { - // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var newBranch = await _fixture.Edit(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - } - - [IntegrationTest] - public async Task ProtectsBranch() - { - // Set master branch to be protected, with some status checks - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1", "check2", "check3" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var branch = await _fixture.Edit(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.Get(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the changes were made - Assert.Equal(branch.Protection.Enabled, true); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Everyone); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 3); - } - - [IntegrationTest] - public async Task RemoveStatusCheckEnforcement() - { - await CreateTheWorld(); - - // Remove status check enforcement - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Off, new List { "check1" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(true, requiredStatusChecks); - - var branch = await _fixture.Edit(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.Get(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the changes were made - Assert.Equal(branch.Protection.Enabled, true); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 1); - } - - [IntegrationTest] - public async Task UnprotectsBranch() - { - await CreateTheWorld(); - - // Unprotect branch - // Deliberately set Enforcement and Contexts to some values (these should be ignored) - var requiredStatusChecks = new RequiredStatusChecks(EnforcementLevel.Everyone, new List { "check1" }); - - var update = new BranchUpdate(); - update.Protection = new BranchProtection(false, requiredStatusChecks); - - var branch = await _fixture.Edit(_context.Repository.Owner.Login, _context.Repository.Name, "master", update); - - // Ensure a branch object was returned - Assert.NotNull(branch); - - // Retrieve master branch - branch = await _fixture.Get(_context.Repository.Owner.Login, _context.Repository.Name, "master"); - - // Assert the branch is unprotected, and enforcement/contexts are cleared - Assert.Equal(branch.Protection.Enabled, false); - Assert.Equal(branch.Protection.RequiredStatusChecks.EnforcementLevel, EnforcementLevel.Off); - Assert.Equal(branch.Protection.RequiredStatusChecks.Contexts.Count, 0); - } - } - public class TheGetBranchProtectionMethod : IDisposable { IRepositoryBranchesClient _client; diff --git a/Octokit.Tests/Clients/RepositoriesClientTests.cs b/Octokit.Tests/Clients/RepositoriesClientTests.cs index 3438d103..12fcbb09 100644 --- a/Octokit.Tests/Clients/RepositoriesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoriesClientTests.cs @@ -1159,58 +1159,6 @@ namespace Octokit.Tests.Clients } } - public class TheEditBranchMethod - { - [Fact] - public void RequestsTheCorrectUrl() - { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - var update = new BranchUpdate(); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; - - client.EditBranch("owner", "repo", "branch", update); - - connection.Received() - .Patch(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch"), Arg.Any(), previewAcceptsHeader); - } - - [Fact] - public void RequestsTheCorrectUrlWithRepositoryId() - { - var connection = Substitute.For(); - var client = new RepositoriesClient(connection); - var update = new BranchUpdate(); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; - - client.EditBranch(1, "branch", update); - - connection.Received() - .Patch(Arg.Is(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any(), previewAcceptsHeader); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoriesClient(Substitute.For()); - var update = new BranchUpdate(); - - await Assert.ThrowsAsync(() => client.EditBranch(null, "repo", "branch", update)); - await Assert.ThrowsAsync(() => client.EditBranch("owner", null, "branch", update)); - await Assert.ThrowsAsync(() => client.EditBranch("owner", "repo", null, update)); - await Assert.ThrowsAsync(() => client.EditBranch("owner", "repo", "branch", null)); - - await Assert.ThrowsAsync(() => client.EditBranch(1, null, update)); - await Assert.ThrowsAsync(() => client.EditBranch(1, "branch", null)); - - await Assert.ThrowsAsync(() => client.EditBranch("", "repo", "branch", update)); - await Assert.ThrowsAsync(() => client.EditBranch("owner", "", "branch", update)); - await Assert.ThrowsAsync(() => client.EditBranch("owner", "repo", "", update)); - - await Assert.ThrowsAsync(() => client.EditBranch(1, "", update)); - } - } - public class TheGetSha1Method { [Fact] diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs index bcec09a2..2650890e 100644 --- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs @@ -150,58 +150,6 @@ namespace Octokit.Tests.Clients } } - public class TheEditMethod - { - [Fact] - public void RequestsTheCorrectUrl() - { - var connection = Substitute.For(); - var client = new RepositoryBranchesClient(connection); - var update = new BranchUpdate(); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; - - client.Edit("owner", "repo", "branch", update); - - connection.Received() - .Patch(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch"), Arg.Any(), previewAcceptsHeader); - } - - [Fact] - public void RequestsTheCorrectUrlWithRepositoryId() - { - var connection = Substitute.For(); - var client = new RepositoryBranchesClient(connection); - var update = new BranchUpdate(); - const string previewAcceptsHeader = "application/vnd.github.loki-preview+json"; - - client.Edit(1, "branch", update); - - connection.Received() - .Patch(Arg.Is(u => u.ToString() == "repositories/1/branches/branch"), Arg.Any(), previewAcceptsHeader); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new RepositoryBranchesClient(Substitute.For()); - var update = new BranchUpdate(); - - await Assert.ThrowsAsync(() => client.Edit(null, "repo", "branch", update)); - await Assert.ThrowsAsync(() => client.Edit("owner", null, "branch", update)); - await Assert.ThrowsAsync(() => client.Edit("owner", "repo", null, update)); - await Assert.ThrowsAsync(() => client.Edit("owner", "repo", "branch", null)); - - await Assert.ThrowsAsync(() => client.Edit(1, null, update)); - await Assert.ThrowsAsync(() => client.Edit(1, "branch", null)); - - await Assert.ThrowsAsync(() => client.Edit("", "repo", "branch", update)); - await Assert.ThrowsAsync(() => client.Edit("owner", "", "branch", update)); - await Assert.ThrowsAsync(() => client.Edit("owner", "repo", "", update)); - - await Assert.ThrowsAsync(() => client.Edit(1, "", update)); - } - } - public class TheGetBranchProtectectionMethod { [Fact] diff --git a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs index 7ff37bd3..565b4ba5 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoriesClientTests.cs @@ -924,54 +924,6 @@ namespace Octokit.Tests.Reactive } } - public class TheEditBranchMethod - { - [Fact] - public void PatchsTheCorrectUrl() - { - var github = Substitute.For(); - var client = new ObservableRepositoriesClient(github); - var update = new BranchUpdate(); - - client.EditBranch("owner", "repo", "branch", update); - - github.Repository.Branch.Received(1).Edit("owner", "repo", "branch", update); - } - - [Fact] - public void PatchsTheCorrectUrlWithRepositoryId() - { - var github = Substitute.For(); - var client = new ObservableRepositoriesClient(github); - var update = new BranchUpdate(); - - client.EditBranch(1, "branch", update); - - github.Repository.Branch.Received(1).Edit(1, "branch", update); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new ObservableRepositoriesClient(Substitute.For()); - var update = new BranchUpdate(); - - Assert.Throws(() => client.EditBranch(null, "repo", "branch", update)); - Assert.Throws(() => client.EditBranch("owner", null, "branch", update)); - Assert.Throws(() => client.EditBranch("owner", "repo", null, update)); - Assert.Throws(() => client.EditBranch("owner", "repo", "branch", null)); - - Assert.Throws(() => client.EditBranch(1, null, update)); - Assert.Throws(() => client.EditBranch(1, "branch", null)); - - Assert.Throws(() => client.EditBranch("", "repo", "branch", update)); - Assert.Throws(() => client.EditBranch("owner", "", "branch", update)); - Assert.Throws(() => client.EditBranch("owner", "repo", "", update)); - - Assert.Throws(() => client.EditBranch(1, "", update)); - } - } - static IResponse CreateResponseWithApiInfo(IDictionary links) { var response = Substitute.For(); diff --git a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs index 78e2ec23..6ff3ed92 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryBranchesClientTests.cs @@ -149,54 +149,6 @@ namespace Octokit.Tests.Reactive } } - public class TheEditMethod - { - [Fact] - public void RequestsTheCorrectUrl() - { - var github = Substitute.For(); - var client = new ObservableRepositoryBranchesClient(github); - var update = new BranchUpdate(); - - client.Edit("owner", "repo", "branch", update); - - github.Repository.Branch.Received(1).Edit("owner", "repo", "branch", update); - } - - [Fact] - public void RequestsTheCorrectUrlWithRepositoryId() - { - var github = Substitute.For(); - var client = new ObservableRepositoryBranchesClient(github); - var update = new BranchUpdate(); - - client.Edit(1, "branch", update); - - github.Repository.Branch.Received(1).Edit(1, "branch", update); - } - - [Fact] - public async Task EnsuresNonNullArguments() - { - var client = new ObservableRepositoryBranchesClient(Substitute.For()); - var update = new BranchUpdate(); - - Assert.Throws(() => client.Edit(null, "repo", "branch", update)); - Assert.Throws(() => client.Edit("owner", null, "branch", update)); - Assert.Throws(() => client.Edit("owner", "repo", null, update)); - Assert.Throws(() => client.Edit("owner", "repo", "branch", null)); - - Assert.Throws(() => client.Edit(1, null, update)); - Assert.Throws(() => client.Edit(1, "branch", null)); - - Assert.Throws(() => client.Edit("", "repo", "branch", update)); - Assert.Throws(() => client.Edit("owner", "", "branch", update)); - Assert.Throws(() => client.Edit("owner", "repo", "", update)); - - Assert.Throws(() => client.Edit(1, "", update)); - } - } - public class TheGetBranchProtectectionMethod { [Fact] diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 3d15d2dc..65a43d26 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -617,27 +617,6 @@ namespace Octokit /// The updated Task Edit(long repositoryId, RepositoryUpdate update); - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the RepositoryBranchesClient methods instead.")] - Task EditBranch(string owner, string name, string branch, BranchUpdate update); - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the RepositoryBranchesClient methods instead.")] - Task EditBranch(long repositoryId, string branch, BranchUpdate update); - /// /// A client for GitHub's Repository Pages API. /// diff --git a/Octokit/Clients/IRepositoryBranchesClient.cs b/Octokit/Clients/IRepositoryBranchesClient.cs index be4f6d0a..9f0c2e56 100644 --- a/Octokit/Clients/IRepositoryBranchesClient.cs +++ b/Octokit/Clients/IRepositoryBranchesClient.cs @@ -77,25 +77,6 @@ namespace Octokit [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] Task Get(long repositoryId, string branch); - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other RepositoryBranchesClient methods instead.")] - Task Edit(string owner, string name, string branch, BranchUpdate update); - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other RepositoryBranchesClient methods instead.")] - Task Edit(long repositoryId, string branch, BranchUpdate update); - /// /// Get the branch protection settings for the specified branch /// diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index 22adc823..4c8564d6 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -208,41 +208,6 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.Repository(repositoryId), update, AcceptHeaders.SquashCommitPreview); } - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the RepositoryBranchesClient methods instead.")] - public Task EditBranch(string owner, string name, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return Branch.Edit(owner, name, branch, update); - } - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - /// The updated - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use the RepositoryBranchesClient methods instead.")] - public Task EditBranch(long repositoryId, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return Branch.Edit(repositoryId, branch, update); - } - /// /// Gets the specified repository. /// diff --git a/Octokit/Clients/RepositoryBranchesClient.cs b/Octokit/Clients/RepositoryBranchesClient.cs index 2ac509ec..2c1ad4c0 100644 --- a/Octokit/Clients/RepositoryBranchesClient.cs +++ b/Octokit/Clients/RepositoryBranchesClient.cs @@ -117,39 +117,6 @@ namespace Octokit return ApiConnection.Get(ApiUrls.RepoBranch(repositoryId, branch), null, AcceptHeaders.ProtectedBranchesApiPreview); } - /// - /// Edit the specified branch with the values given in - /// - /// The owner of the repository - /// The name of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other RepositoryBranchesClient methods instead.")] - public Task Edit(string owner, string name, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return ApiConnection.Patch(ApiUrls.RepoBranch(owner, name, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); - } - - /// - /// Edit the specified branch with the values given in - /// - /// The Id of the repository - /// The name of the branch - /// New values to update the branch with - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use other RepositoryBranchesClient methods instead.")] - public Task Edit(long repositoryId, string branch, BranchUpdate update) - { - Ensure.ArgumentNotNullOrEmptyString(branch, "branch"); - Ensure.ArgumentNotNull(update, "update"); - - return ApiConnection.Patch(ApiUrls.RepoBranch(repositoryId, branch), update, AcceptHeaders.ProtectedBranchesApiPreview); - } - /// /// Get the branch protection settings for the specified branch /// diff --git a/Octokit/Models/Request/BranchUpdate.cs b/Octokit/Models/Request/BranchUpdate.cs deleted file mode 100644 index d65dd0ae..00000000 --- a/Octokit/Models/Request/BranchUpdate.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Diagnostics; -using System.Globalization; - -namespace Octokit -{ - /// - /// Specifies the values used to update a . - /// - /// - /// Note: this is a PREVIEW api: https://developer.github.com/changes/2015-11-11-protected-branches-api/ - /// - [DebuggerDisplay("{DebuggerDisplay,nq}")] - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please use BranchProtectionSettingsUpdate instead.")] - public class BranchUpdate - { - /// - /// The details - /// - public BranchProtection Protection { get; set; } - - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, "Protection: {0}", Protection.DebuggerDisplay); - } - } - } -} diff --git a/Octokit/Models/Response/Branch.cs b/Octokit/Models/Response/Branch.cs index 153d446f..78c8a76b 100644 --- a/Octokit/Models/Response/Branch.cs +++ b/Octokit/Models/Response/Branch.cs @@ -16,32 +16,11 @@ namespace Octokit Protected = @protected; } -#pragma warning disable CS0618 // Type or member is obsolete - public Branch(string name, GitReference commit, BranchProtection protection) - : this(name, commit, protection, false) - { - } -#pragma warning restore CS0618 // Type or member is obsolete - -#pragma warning disable CS0618 // Type or member is obsolete - public Branch(string name, GitReference commit, BranchProtection protection, bool @protected) - : this(name, commit, @protected) - { - Protection = protection; - } -#pragma warning restore CS0618 // Type or member is obsolete - /// /// Name of this . /// public string Name { get; protected set; } - /// - /// The details for this . - /// - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please see the Branch.Protected property and RepositoryBranchesClient.GetBranchProtection method instead.")] - public BranchProtection Protection { get; protected set; } - /// /// Whether this is protected. /// diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index 2c4f5d7b..36e3111c 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -8,99 +8,6 @@ using Octokit.Internal; namespace Octokit { - /// - /// Protection details for a . - /// - /// - /// Note: this is a PREVIEW api: https://developer.github.com/changes/2015-11-11-protected-branches-api/ - /// - [DebuggerDisplay("{DebuggerDisplay,nq}")] - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please see BranchProtectionSettings instead.")] - public class BranchProtection - { - public BranchProtection() { } - - public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks) - { - Enabled = enabled; - RequiredStatusChecks = requiredStatusChecks; - } - - /// - /// Should this branch be protected or not - /// - public bool Enabled { get; protected set; } - - /// - /// The information for this . - /// - public RequiredStatusChecks RequiredStatusChecks { get; private set; } - - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, "Enabled: {0}", Enabled); - } - } - } - - [DebuggerDisplay("{DebuggerDisplay,nq}")] - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please see BranchProtectionRequiredStatusChecks instead.")] - public class RequiredStatusChecks - { - public RequiredStatusChecks() { } - - public RequiredStatusChecks(EnforcementLevel enforcementLevel, IEnumerable contexts) - { - EnforcementLevel = enforcementLevel; - Contexts = new ReadOnlyCollection(contexts.ToList()); - } - - /// - /// Who required status checks apply to - /// - public StringEnum EnforcementLevel { get; protected set; } - - /// - /// The list of status checks to require in order to merge into this - /// - public IReadOnlyList Contexts { get; private set; } - - internal string DebuggerDisplay - { - get - { - return string.Format(CultureInfo.InvariantCulture, "EnforcementLevel: {0} Contexts: {1}", EnforcementLevel.ToString(), Contexts.Count); - } - } - } - - /// - /// The enforcement levels that are available - /// - [Obsolete("This existing implementation will cease to work when the Branch Protection API preview period ends. Please see BranchProtection.EnforceAdmins instead.")] - public enum EnforcementLevel - { - /// - /// Turn off required status checks for this . - /// - [Parameter(Value = "off")] - Off, - - /// - /// Required status checks will be enforced for non-admins. - /// - [Parameter(Value = "non_admins")] - NonAdmins, - - /// - /// Required status checks will be enforced for everyone (including admins). - /// - [Parameter(Value = "everyone")] - Everyone - } - /// /// Protection details for a . ///