mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
feat: New pull request from existing issue (#2389)
This commit is contained in:
@@ -49,6 +49,18 @@ public class PullRequestsClientTests : IDisposable
|
||||
Assert.True(result.Draft);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateFromIssue()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
var newIssue = await _github.Issue.Create(Helper.UserName, _context.RepositoryName, new NewIssue("an issue"));
|
||||
var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master");
|
||||
var result = await _fixture.Create(Helper.UserName, _context.RepositoryName, newPullRequest);
|
||||
Assert.Equal(newIssue.Number, result.Number);
|
||||
Assert.Equal(newIssue.Title, result.Title);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateWithRepositoryId()
|
||||
{
|
||||
@@ -70,6 +82,18 @@ public class PullRequestsClientTests : IDisposable
|
||||
Assert.True(result.Draft);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateFromIssueWithRepositoryId()
|
||||
{
|
||||
await CreateTheWorld();
|
||||
|
||||
var newIssue = await _github.Issue.Create(_context.RepositoryId, new NewIssue("an issue"));
|
||||
var newPullRequest = new NewPullRequest(newIssue.Number, branchName, "master");
|
||||
var result = await _fixture.Create(_context.Repository.Id, newPullRequest);
|
||||
Assert.Equal(newIssue.Number, result.Number);
|
||||
Assert.Equal(newIssue.Title, result.Title);
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanGetForRepository()
|
||||
{
|
||||
|
||||
@@ -27,10 +27,31 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Title of the pull request (required)
|
||||
/// Initializes a new instance of the <see cref="NewPullRequest"/> class.
|
||||
/// </summary>
|
||||
/// <param name="issueId">The number of an existing issue to convert into a pull request.</param>
|
||||
/// <param name="head">The branch (or git ref where your changes are implemented. In other words, the source branch/ref</param>
|
||||
/// <param name="baseRef">The base (or git ref) reference you want your changes pulled into. In other words, the target branch/ref</param>
|
||||
public NewPullRequest(int issueId, string head, string baseRef)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(head, nameof(head));
|
||||
Ensure.ArgumentNotNullOrEmptyString(baseRef, nameof(baseRef));
|
||||
|
||||
IssueId = issueId;
|
||||
Head = head;
|
||||
Base = baseRef;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Title of the pull request (required if <see cref="Issue"/> not provided).
|
||||
/// </summary>
|
||||
public string Title { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of an existing issue to convert into a pull request (required if <see cref="Title"/> not provided).
|
||||
/// </summary>
|
||||
public int? IssueId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The branch (or git ref) you want your changes pulled into (required).
|
||||
/// </summary>
|
||||
@@ -60,7 +81,14 @@ namespace Octokit
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Title: {0}", Title);
|
||||
if (Title == null)
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "Title: {0}", Title);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "From Issue: {0}", IssueId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user