using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
///
/// Describes a new pull request to create via the method.
///
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewPullRequest
{
///
/// Initializes a new instance of the class.
///
/// The title of the pull request.
/// The branch (or git ref where your changes are implemented. In other words, the source branch/ref
/// The base (or git ref) reference you want your changes pulled into. In other words, the target branch/ref
public NewPullRequest(string title, string head, string baseRef)
{
Ensure.ArgumentNotNullOrEmptyString(title, nameof(title));
Ensure.ArgumentNotNullOrEmptyString(head, nameof(head));
Ensure.ArgumentNotNullOrEmptyString(baseRef, nameof(baseRef));
Title = title;
Head = head;
Base = baseRef;
}
///
/// Initializes a new instance of the class.
///
/// The number of an existing issue to convert into a pull request.
/// The branch (or git ref where your changes are implemented. In other words, the source branch/ref
/// The base (or git ref) reference you want your changes pulled into. In other words, the target branch/ref
public NewPullRequest(long issueId, string head, string baseRef)
{
Ensure.ArgumentNotNullOrEmptyString(head, nameof(head));
Ensure.ArgumentNotNullOrEmptyString(baseRef, nameof(baseRef));
IssueId = issueId;
Head = head;
Base = baseRef;
}
///
/// Title of the pull request (required if not provided).
///
public string Title { get; private set; }
///
/// The number of an existing issue to convert into a pull request (required if not provided).
///
public long? IssueId { get; private set; }
///
/// The branch (or git ref) you want your changes pulled into (required).
///
public string Base { get; private set; }
///
/// The branch (or git ref) where your changes are implemented (required).
///
public string Head { get; private set; }
///
/// Whether maintainers of the base repository can push to the HEAD branch (optional).
///
public bool? MaintainerCanModify { get; set; }
///
/// Body of the pull request (optional)
///
public string Body { get; set; }
///
/// Whether the pull request is in a draft state or not (optional)
///
public bool? Draft { get; set; }
internal string DebuggerDisplay
{
get
{
if (Title == null)
{
return string.Format(CultureInfo.InvariantCulture, "Title: {0}", Title);
}
else
{
return string.Format(CultureInfo.InvariantCulture, "From Issue: {0}", IssueId);
}
}
}
}
}