diff --git a/Octokit.Reactive/Clients/IObservableMergingClient.cs b/Octokit.Reactive/Clients/IObservableMergingClient.cs
new file mode 100644
index 00000000..8819a2cd
--- /dev/null
+++ b/Octokit.Reactive/Clients/IObservableMergingClient.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace Octokit.Reactive
+{
+ public interface IObservableMergingClient
+ {
+ ///
+ /// Create a merge for a given repository
+ ///
+ ///
+ /// http://developer.github.com/v3/repos/merging/#perform-a-merge
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The merge to create
+ ///
+ IObservable Create(string owner, string name, NewMerge merge);
+ }
+}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
index 4b084ba5..24369e90 100644
--- a/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/IObservableRepositoriesClient.cs
@@ -133,6 +133,14 @@ namespace Octokit.Reactive
///
IObservableRepositoryContentsClient Content { get; }
+ ///
+ /// Client for GitHub's Repository Merging API
+ ///
+ ///
+ /// See the Merging API documentation for more details
+ ///
+ IObservableMergingClient Merging { get; }
+
///
/// Gets all the branches for the specified repository.
///
diff --git a/Octokit.Reactive/Clients/ObservableMergingClient.cs b/Octokit.Reactive/Clients/ObservableMergingClient.cs
new file mode 100644
index 00000000..4523d2f4
--- /dev/null
+++ b/Octokit.Reactive/Clients/ObservableMergingClient.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Reactive.Threading.Tasks;
+
+namespace Octokit.Reactive
+{
+ public class ObservableMergingClient : IObservableMergingClient
+ {
+ readonly IMergingClient _client;
+
+ public ObservableMergingClient(IGitHubClient client)
+ {
+ Ensure.ArgumentNotNull(client, "client");
+ _client = client.Repository.Merging;
+ }
+
+ ///
+ /// Create a merge for a given repository
+ ///
+ ///
+ /// http://developer.github.com/v3/repos/merging/#perform-a-merge
+ ///
+ /// The owner of the repository
+ /// The name of the repository
+ /// The merge to create
+ ///
+ public IObservable Create(string owner, string name, NewMerge merge)
+ {
+ return _client.Create(owner, name, merge).ToObservable();
+ }
+ }
+}
diff --git a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
index bbc7d220..5fa2f7a5 100644
--- a/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
+++ b/Octokit.Reactive/Clients/ObservableRepositoriesClient.cs
@@ -28,6 +28,7 @@ namespace Octokit.Reactive
Commits = new ObservableRepositoryCommitsClient(client);
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
Content = new ObservableRepositoryContentsClient(client);
+ Merging = new ObservableMergingClient(client);
}
///
@@ -196,6 +197,15 @@ namespace Octokit.Reactive
///
public IObservableRepositoryContentsClient Content { get; private set; }
+
+ ///
+ /// Client for GitHub's Repository Merging API
+ ///
+ ///
+ /// See the Merging API documentation for more details
+ ///
+ public IObservableMergingClient Merging { get; private set; }
+
///
/// Gets all the branches for the specified repository.
///
diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
index b8b170ae..25f81385 100644
--- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Mono.csproj
@@ -150,6 +150,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
index bb4d6a4a..e663b82d 100644
--- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj
@@ -159,6 +159,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
index 8bedcbdf..a1441ae8 100644
--- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
+++ b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj
@@ -154,6 +154,8 @@
+
+
diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj
index 3ca9d049..19db4fc6 100644
--- a/Octokit.Reactive/Octokit.Reactive.csproj
+++ b/Octokit.Reactive/Octokit.Reactive.csproj
@@ -74,10 +74,12 @@
Properties\SolutionInfo.cs
+
+
@@ -200,4 +202,4 @@
-->
-
+
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/MergingClientTests.cs b/Octokit.Tests.Integration/Clients/MergingClientTests.cs
index a5d9d258..31545759 100644
--- a/Octokit.Tests.Integration/Clients/MergingClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/MergingClientTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
@@ -10,8 +11,9 @@ public class MergingClientTests : IDisposable
readonly Repository _repository;
readonly string _owner;
readonly IMergingClient _fixture;
- readonly ICommitsClient _commitsClient;
-
+
+ const string branchName = "my-branch";
+
public MergingClientTests()
{
_client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
@@ -20,8 +22,7 @@ public class MergingClientTests : IDisposable
};
var repoName = Helper.MakeNameWithTimestamp("public-repo");
- _fixture = _client.GitDatabase.Merging;
- _commitsClient = _client.GitDatabase.Commit;
+ _fixture = _client.Repository.Merging;
_repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
_owner = _repository.Owner.Login;
}
@@ -29,33 +30,70 @@ public class MergingClientTests : IDisposable
[IntegrationTest]
public async Task CanCreateMerge()
{
- var blob = new NewBlob
- {
- Content = "Hello World!",
- Encoding = EncodingType.Utf8
- };
- var blobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, blob);
-
- var newTree = new NewTree();
- newTree.Tree.Add(new NewTreeItem
- {
- Type = TreeType.Blob,
- Mode = FileMode.File,
- Path = "README.md",
- Sha = blobResult.Sha
- });
-
- var treeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, newTree);
-
- var newCommit = new NewCommit("test-commit", treeResult.Sha);
-
- var commit = await _commitsClient.Create(_owner, _repository.Name, newCommit);
- Assert.NotNull(commit);
-
- var newMerge = new NewMerge("master", commit.Sha, "merge commit to master from integrationtests");
+ await CreateTheWorld();
+
+ var newMerge = new NewMerge("master", branchName, "merge commit to master from integrationtests");
var merge = await _fixture.Create(_owner, _repository.Name, newMerge);
Assert.NotNull(merge);
+ Assert.NotNull(merge.Commit);
+ Assert.Equal("merge commit to master from integrationtests", merge.Commit.Message);
+ }
+
+ async Task CreateTheWorld()
+ {
+ var master = await _client.GitDatabase.Reference.Get(Helper.UserName, _repository.Name, "heads/master");
+
+ // create new commit for master branch
+ var newMasterTree = await CreateTree(new Dictionary { { "README.md", "Hello World! I want to be overwritten by featurebranch!" } });
+ var newMaster = await CreateCommit("baseline for merge", newMasterTree.Sha, master.Object.Sha);
+
+ // update master
+ await _client.GitDatabase.Reference.Update(Helper.UserName, _repository.Name, "heads/master", new ReferenceUpdate(newMaster.Sha));
+
+ // create new commit for feature branch
+ var featureBranchTree = await CreateTree(new Dictionary { { "README.md", "I am overwriting this blob with something new" } });
+ var featureBranchCommit = await CreateCommit("this is the commit to merge", featureBranchTree.Sha, newMaster.Sha);
+
+ // create branch
+ await _client.GitDatabase.Reference.Create(Helper.UserName, _repository.Name, new NewReference("refs/heads/my-branch", featureBranchCommit.Sha));
+ }
+
+ async Task CreateTree(IEnumerable> treeContents)
+ {
+ var collection = new List();
+
+ foreach (var c in treeContents)
+ {
+ var baselineBlob = new NewBlob
+ {
+ Content = c.Value,
+ Encoding = EncodingType.Utf8
+ };
+ var baselineBlobResult = await _client.GitDatabase.Blob.Create(Helper.UserName, _repository.Name, baselineBlob);
+
+ collection.Add(new NewTreeItem
+ {
+ Type = TreeType.Blob,
+ Mode = FileMode.File,
+ Path = c.Key,
+ Sha = baselineBlobResult.Sha
+ });
+ }
+
+ var newTree = new NewTree();
+ foreach (var item in collection)
+ {
+ newTree.Tree.Add(item);
+ }
+
+ return await _client.GitDatabase.Tree.Create(Helper.UserName, _repository.Name, newTree);
+ }
+
+ async Task CreateCommit(string message, string sha, string parent)
+ {
+ var newCommit = new NewCommit(message, sha, parent);
+ return await _client.GitDatabase.Commit.Create(Helper.UserName, _repository.Name, newCommit);
}
public void Dispose()
diff --git a/Octokit.sln.DotSettings b/Octokit.sln.DotSettings
index 0992e585..3ceaf708 100644
--- a/Octokit.sln.DotSettings
+++ b/Octokit.sln.DotSettings
@@ -262,5 +262,7 @@ II.2.12 <HandlesEvent />
<Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
<Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" />
+ True
True
+ True
\ No newline at end of file
diff --git a/Octokit/Clients/GitDatabaseClient.cs b/Octokit/Clients/GitDatabaseClient.cs
index fe1be7c8..4265df77 100644
--- a/Octokit/Clients/GitDatabaseClient.cs
+++ b/Octokit/Clients/GitDatabaseClient.cs
@@ -19,7 +19,6 @@
Tree = new TreesClient(apiConnection);
Tag = new TagsClient(apiConnection);
Commit = new CommitsClient(apiConnection);
- Merging = new MergingClient(apiConnection);
Reference = new ReferencesClient(apiConnection);
}
@@ -27,7 +26,6 @@
public ITreesClient Tree { get; private set; }
public ITagsClient Tag { get; private set; }
public ICommitsClient Commit { get; private set; }
- public IMergingClient Merging { get; private set; }
public IReferencesClient Reference { get; private set; }
}
}
\ No newline at end of file
diff --git a/Octokit/Clients/IGitDatabaseClient.cs b/Octokit/Clients/IGitDatabaseClient.cs
index 0ff1306d..328fde5f 100644
--- a/Octokit/Clients/IGitDatabaseClient.cs
+++ b/Octokit/Clients/IGitDatabaseClient.cs
@@ -12,7 +12,6 @@
ITagsClient Tag { get; }
ITreesClient Tree { get; }
ICommitsClient Commit { get; }
- IMergingClient Merging { get; }
IReferencesClient Reference { get; }
}
}
\ No newline at end of file
diff --git a/Octokit/Models/Response/Merge.cs b/Octokit/Models/Response/Merge.cs
index 91a150b5..bb5ce647 100644
--- a/Octokit/Models/Response/Merge.cs
+++ b/Octokit/Models/Response/Merge.cs
@@ -6,11 +6,25 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Merge : GitReference
{
- public string Message { get; set; }
- public Signature Author { get; set; }
- public Signature Committer { get; set; }
- public GitReference Tree { get; set; }
- public IEnumerable Parents { get; set; }
- public int CommentCount { get; set; }
+ public Merge() { }
+
+ public Merge(Author author, Author committer, Commit commit, IEnumerable parents, string commentsUrl, int commentCount, string htmlUrl)
+ {
+ Author = author;
+ Committer = committer;
+ Commit = commit;
+ Parents = parents;
+ CommentsUrl = commentsUrl;
+ CommentCount = commentCount;
+ HtmlUrl = htmlUrl;
+ }
+
+ public Author Author { get; protected set; }
+ public Author Committer { get; protected set; }
+ public Commit Commit { get; protected set; }
+ public IEnumerable Parents { get; protected set; }
+ public string CommentsUrl { get; protected set; }
+ public int CommentCount { get; protected set; }
+ public string HtmlUrl { get; protected set; }
}
}
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 1b821073..b02ab4a0 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -67,9 +67,11 @@
+
+
@@ -89,6 +91,7 @@
+
@@ -111,6 +114,7 @@
+
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 6c10f91b..eff1accd 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -62,9 +62,11 @@
+
+
@@ -84,6 +86,7 @@
+
@@ -108,6 +111,7 @@
+
diff --git a/SolutionInfo.cs b/SolutionInfo.cs
index f3469380..71834b6a 100644
--- a/SolutionInfo.cs
+++ b/SolutionInfo.cs
@@ -3,11 +3,11 @@ using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyProductAttribute("Octokit")]
-[assembly: AssemblyVersionAttribute("0.6.2")]
-[assembly: AssemblyFileVersionAttribute("0.6.2")]
+[assembly: AssemblyVersionAttribute("0.6.3")]
+[assembly: AssemblyFileVersionAttribute("0.6.3")]
[assembly: ComVisibleAttribute(false)]
namespace System {
internal static class AssemblyVersionInformation {
- internal const string Version = "0.6.2";
+ internal const string Version = "0.6.3";
}
}