Pull-Request-Squash-Commit (#1245)

This commit is contained in:
Sarmad
2016-05-20 13:34:41 +05:00
committed by Brendan Forster
parent 1b51717f8d
commit 3f3930253c
5 changed files with 34 additions and 3 deletions
@@ -225,6 +225,24 @@ public class PullRequestsClientTests : IDisposable
}
[IntegrationTest]
public async Task CanBeMergedWithSquashCommit()
{
await CreateTheWorld();
var newPullRequest = new NewPullRequest("squash commit pull request", branchName, "master");
var pullRequest = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);
var merge = new MergePullRequest { CommitMessage = "fake commit message", CommitTitle = "fake title", Squash = true };
var result = await _fixture.Merge(Helper.UserName, _context.RepositoryName, pullRequest.Number, merge);
var commit = await _github.Repository.Commit.Get(_context.RepositoryOwner, _context.RepositoryName, result.Sha);
var message = commit.Commit.Message;
Assert.True(result.Merged);
Assert.Equal("fake title\n\nfake commit message", commit.Commit.Message);
}
[IntegrationTest]
public async Task CannotBeMergedDueMismatchConflict()
{
await CreateTheWorld();
@@ -145,7 +145,7 @@ namespace Octokit.Tests.Clients
client.Merge("fake", "repo", 42, mergePullRequest);
connection.Received().Put<PullRequestMerge>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/pulls/42/merge"),
mergePullRequest);
mergePullRequest,null, "application/vnd.github.polaris-preview+json");
}
[Fact]
+2 -1
View File
@@ -119,7 +119,8 @@ namespace Octokit
try
{
var endpoint = ApiUrls.MergePullRequest(owner, name, number);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest).ConfigureAwait(false);
return await ApiConnection.Put<PullRequestMerge>(endpoint, mergePullRequest,null,
AcceptHeaders.SquashCommitPreview).ConfigureAwait(false);
}
catch (ApiException ex)
{
+2
View File
@@ -17,5 +17,7 @@
public const string IssueLockingUnlockingApiPreview = "application/vnd.github.the-key-preview+json";
public const string CommitReferenceSha1Preview = "application/vnd.github.chitauri-preview+sha";
public const string SquashCommitPreview = "application/vnd.github.polaris-preview+json";
}
}
+11 -1
View File
@@ -22,11 +22,21 @@ namespace Octokit
/// </summary>
public string Sha { get; set; }
/// <summary>
/// The Title for the automatic commit message (optional)
/// </summary>
public string CommitTitle { get; set; }
/// <summary>
/// Commit a single commit to the head branch (optional)
/// </summary>
public bool Squash { get; set; }
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Message: '{0}', Sha: '{1}'", CommitMessage, Sha);
return string.Format(CultureInfo.InvariantCulture, "Title: '{0}' Message: '{1}', Sha: '{2}' , Squash: '{3}'", CommitTitle, CommitMessage, Sha, Squash);
}
}
}