diff --git a/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs
index eb9e41c26d..a37cb260e2 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoryBranchesClient.cs
@@ -1,15 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-
namespace Octokit.Reactive
{
- ///
- /// A client for GitHub's Repository Branches API.
- ///
- ///
- /// See the Repository Branches API documentation for more details.
- ///
+ ///
+ /// A client for GitHub's Repository Branches API.
+ ///
+ ///
+ /// See the Repository Branches API documentation for more details.
+ ///
public interface IObservableRepositoryBranchesClient
{
///
@@ -644,5 +643,17 @@ public interface IObservableRepositoryBranchesClient
/// The name of the branch
/// List of users with push access to remove
IObservable DeleteProtectedBranchUserRestrictions(long repositoryId, string branch, BranchProtectionUserCollection users);
+
+ ///
+ /// Renames a branch in a repository
+ ///
+ ///
+ /// See the API documentation for more details
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The name of the branch to rename
+ /// The new name of the branch
+ IObservable RenameBranch(string owner, string repository, string branch, string newName);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs
index ac87bb1b0d..8eea00feab 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoryBranchesClient.cs
@@ -3,6 +3,8 @@
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
+using System.Threading.Tasks;
+
using Octokit.Reactive.Internal;
namespace Octokit.Reactive
@@ -297,7 +299,7 @@ public IObservable UpdateRequiredStatusChe
///
/// The owner of the repository
/// The name of the repository
- /// The name of the branch
+ /// The name of the branch
public IObservable DeleteRequiredStatusChecks(string owner, string name, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
@@ -314,7 +316,7 @@ public IObservable DeleteRequiredStatusChecks(string owner, string name, s
/// See the API documentation for more details
///
/// The Id of the repository
- /// The name of the branch
+ /// The name of the branch
public IObservable DeleteRequiredStatusChecks(long repositoryId, string branch)
{
Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
@@ -1021,5 +1023,25 @@ public IObservable DeleteProtectedBranchUserRestrictions(long repositoryId
return _client.DeleteProtectedBranchUserRestrictions(repositoryId, branch, users).ToObservable().SelectMany(x => x);
}
- }
+
+ ///
+ /// Renames a branch in a repository
+ ///
+ ///
+ /// See the API documentation for more details
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The name of the branch to rename
+ /// The new name of the branch
+ public IObservable RenameBranch(string owner, string repository, string branch, string newName)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
+ Ensure.ArgumentNotNullOrEmptyString(repository, nameof(repository));
+ Ensure.ArgumentNotNullOrEmptyString(branch, nameof(branch));
+ Ensure.ArgumentNotNullOrEmptyString(newName, nameof(newName));
+
+ return _client.RenameBranch(owner, repository, branch, newName).ToObservable();
+ }
+ }
}
diff --git a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs
index 6d5160ec55..ed0aeb8918 100644
--- a/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs
+++ b/Octokit.Tests/Clients/RepositoryBranchesClientTests.cs
@@ -1399,5 +1399,50 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.DeleteProtectedBranchUserRestrictions(1, "", usersToRemove));
}
}
- }
+
+ public class TheRenameBranchMethod
+ {
+ [Fact]
+ public void RequestsTheCorrectUrl()
+ {
+ var connection = Substitute.For();
+ var client = new RepositoryBranchesClient(connection);
+
+ client.RenameBranch("owner", "repo", "branch", "new_name");
+
+ connection.Received()
+ .Post(Arg.Is(u => u.ToString() == "repos/owner/repo/branches/branch/rename"), Arg.Any