mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-21 06:35:11 +00:00
Fixed broken conventions. Wrote a integrationstests that performs an actual merge between two branches.
This commit is contained in:
19
Octokit.Reactive/Clients/IObservableMergingClient.cs
Normal file
19
Octokit.Reactive/Clients/IObservableMergingClient.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableMergingClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a merge for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/repos/merging/#perform-a-merge
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="merge">The merge to create</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Merge> Create(string owner, string name, NewMerge merge);
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,14 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
IObservableRepositoryContentsClient Content { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Merging API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/merging/">Merging API documentation</a> for more details
|
||||
///</remarks>
|
||||
IObservableMergingClient Merging { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
|
||||
31
Octokit.Reactive/Clients/ObservableMergingClient.cs
Normal file
31
Octokit.Reactive/Clients/ObservableMergingClient.cs
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a merge for a given repository
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// http://developer.github.com/v3/repos/merging/#perform-a-merge
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="merge">The merge to create</param>
|
||||
/// <returns></returns>
|
||||
public IObservable<Merge> Create(string owner, string name, NewMerge merge)
|
||||
{
|
||||
return _client.Create(owner, name, merge).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace Octokit.Reactive
|
||||
Commits = new ObservableRepositoryCommitsClient(client);
|
||||
DeployKeys = new ObservableRepositoryDeployKeysClient(client);
|
||||
Content = new ObservableRepositoryContentsClient(client);
|
||||
Merging = new ObservableMergingClient(client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,6 +197,15 @@ namespace Octokit.Reactive
|
||||
/// </remarks>
|
||||
public IObservableRepositoryContentsClient Content { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Client for GitHub's Repository Merging API
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="https://developer.github.com/v3/repos/merging/">Merging API documentation</a> for more details
|
||||
///</remarks>
|
||||
public IObservableMergingClient Merging { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the branches for the specified repository.
|
||||
/// </summary>
|
||||
|
||||
@@ -150,6 +150,8 @@
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -159,6 +159,8 @@
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -154,6 +154,8 @@
|
||||
<Compile Include="Clients\ObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryContentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
@@ -74,10 +74,12 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\IObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\IObservableUserKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableMergingClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryDeployKeysClient.cs" />
|
||||
<Compile Include="Clients\ObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryContentsClient.cs" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
@@ -10,7 +11,8 @@ public class MergingClientTests : IDisposable
|
||||
readonly Repository _repository;
|
||||
readonly string _owner;
|
||||
readonly IMergingClient _fixture;
|
||||
readonly ICommitsClient _commitsClient;
|
||||
|
||||
const string branchName = "my-branch";
|
||||
|
||||
public MergingClientTests()
|
||||
{
|
||||
@@ -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);
|
||||
await CreateTheWorld();
|
||||
|
||||
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");
|
||||
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<string, string> { { "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<string, string> { { "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<TreeResponse> CreateTree(IEnumerable<KeyValuePair<string, string>> treeContents)
|
||||
{
|
||||
var collection = new List<NewTreeItem>();
|
||||
|
||||
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<Commit> 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()
|
||||
|
||||
@@ -262,5 +262,7 @@ II.2.12 <HandlesEvent />
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpFileLayoutPatternsUpgrade/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
||||
</wpf:ResourceDictionary>
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@
|
||||
ITagsClient Tag { get; }
|
||||
ITreesClient Tree { get; }
|
||||
ICommitsClient Commit { get; }
|
||||
IMergingClient Merging { get; }
|
||||
IReferencesClient Reference { get; }
|
||||
}
|
||||
}
|
||||
@@ -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<GitReference> Parents { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
public Merge() { }
|
||||
|
||||
public Merge(Author author, Author committer, Commit commit, IEnumerable<GitReference> 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<GitReference> Parents { get; protected set; }
|
||||
public string CommentsUrl { get; protected set; }
|
||||
public int CommentCount { get; protected set; }
|
||||
public string HtmlUrl { get; protected set; }
|
||||
}
|
||||
}
|
||||
@@ -67,9 +67,11 @@
|
||||
<Compile Include="Clients\IGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IIssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IIssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\IMergingClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\MergingClient.cs" />
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\ITreesClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
@@ -89,6 +91,7 @@
|
||||
<Compile Include="Models\Request\NewBlob.cs" />
|
||||
<Compile Include="Models\Request\NewCommit.cs" />
|
||||
<Compile Include="Models\Request\NewCommitStatus.cs" />
|
||||
<Compile Include="Models\Request\NewMerge.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewPullRequest.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
@@ -111,6 +114,7 @@
|
||||
<Compile Include="Models\Response\IssueComment.cs" />
|
||||
<Compile Include="Models\Response\IssueEvent.cs" />
|
||||
<Compile Include="Models\Response\Label.cs" />
|
||||
<Compile Include="Models\Response\Merge.cs" />
|
||||
<Compile Include="Models\Response\Milestone.cs" />
|
||||
<Compile Include="Models\Request\NewIssue.cs" />
|
||||
<Compile Include="Models\Response\Notification.cs" />
|
||||
|
||||
@@ -62,9 +62,11 @@
|
||||
<Compile Include="Clients\IGitDatabaseClient.cs" />
|
||||
<Compile Include="Clients\IIssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IIssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\IMergingClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\MergingClient.cs" />
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\ITreesClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
@@ -84,6 +86,7 @@
|
||||
<Compile Include="Models\Request\NewBlob.cs" />
|
||||
<Compile Include="Models\Request\NewCommit.cs" />
|
||||
<Compile Include="Models\Request\NewCommitStatus.cs" />
|
||||
<Compile Include="Models\Request\NewMerge.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\NewPullRequest.cs" />
|
||||
<Compile Include="Models\Request\NewTag.cs" />
|
||||
@@ -108,6 +111,7 @@
|
||||
<Compile Include="Models\Response\IssueComment.cs" />
|
||||
<Compile Include="Models\Response\IssueEvent.cs" />
|
||||
<Compile Include="Models\Response\Label.cs" />
|
||||
<Compile Include="Models\Response\Merge.cs" />
|
||||
<Compile Include="Models\Response\Milestone.cs" />
|
||||
<Compile Include="Models\Request\NewIssue.cs" />
|
||||
<Compile Include="Models\Response\Notification.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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user