mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-05-30 09:49:04 +00:00
Pull-Request-Squash-Commit (#1245)
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user