mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-05 23:06:10 +00:00
* Added StringEnum<TEnum> * Added tests * Make sure the serializer can work with StringEnum * Use StringEnum for EventInfo.Event * Add convention test to assert that all Response models use StringEnum<> to wrap enum properties * Add Stringnum<> to all response types failing convention test * Handle StringEnum to Enum conversion when Issue response model populates IssueUpdate request model * Fix unit test * Refactor SimpleJsonSerializer to expose the DeserializeEnum strategy so it can be used in StringEnum class * Need to expose/use SerializeEnum functionality too, so we use the correct string representation of enum values that have custom properties (eg ReactionType Plus1 to "+1") * fix unit tests, since the string is now the "correct" upstream api value * Add a couple of tests for the Enum serialize/deserialize when underscores, hyphens and custom property attributes are present * Compare parsed values for equality * add convention test to ensure enum members all have Parameter property set * update test to cover implicit conversions too * this test should work but fails at the moment due to magic hyphen removal in deserializer causing a one way trip from utf-8 to EncodingType.Utf8 with no way to get back * (unsuccesfully) expand event info test to try to catch more cases of unknown event types * fix broken integration test while im here * Fixed build errors after .NET Core merge * Value -> StringValue, ParsedValue -> Value * Don't allow StringValue to be null * Ignore enums not used in request/response models * Added ParameterAttribute to almost all enum values * Ignore Language enum * Fix failing tests * Fix milestone sort parameter and tests * whitespace * fix milestone unit tests * Fix StringEnum.Equals ... This could've been embarrassing! * Change SimpleJsonSerializer Enum handling to only use `[Parameter()]` attributes (no more magic removal of hyphen/underscores from strings) * Tidy up this integration test while im here * Only test request/response enums in convention test * Keep skipping Language * Remove unused method * Remove excluded enum types * Removed unnecessary ParameterAttributes * Remove unused enum * Add StringEnum test for string-comparison of two invalid values * Bring back IssueCommentSort and use it in IssueCommentRequest This reverts commit 38a4a291d1476ef8c992fe0f76956974b6f32a49. * Use assembly instead of namespace for Octokit check * Add failing test to reproduce the issue where only the first enum paramter/value was added to the cache * Fix deserializer enum cache to include all enum members rather than only the first member encountered * Use a static SimpleJsonSerializer in StringEnum * Remove serializer instance in StringEnum * Add some documentation on StringEnum<TEnum> * Fix parameter value to resolve failing integration test
226 lines
7.5 KiB
C#
226 lines
7.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
|
|
namespace Octokit
|
|
{
|
|
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
|
public class PullRequest
|
|
{
|
|
public PullRequest() { }
|
|
|
|
public PullRequest(int number)
|
|
{
|
|
Number = number;
|
|
}
|
|
|
|
public PullRequest(long id, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList<User> assignees, bool? mergeable, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked, IReadOnlyList<User> requestedReviewers)
|
|
{
|
|
Id = id;
|
|
Url = url;
|
|
HtmlUrl = htmlUrl;
|
|
DiffUrl = diffUrl;
|
|
PatchUrl = patchUrl;
|
|
IssueUrl = issueUrl;
|
|
StatusesUrl = statusesUrl;
|
|
Number = number;
|
|
State = state;
|
|
Title = title;
|
|
Body = body;
|
|
CreatedAt = createdAt;
|
|
UpdatedAt = updatedAt;
|
|
ClosedAt = closedAt;
|
|
MergedAt = mergedAt;
|
|
Head = head;
|
|
Base = @base;
|
|
User = user;
|
|
Assignee = assignee;
|
|
Assignees = assignees;
|
|
Mergeable = mergeable;
|
|
MergedBy = mergedBy;
|
|
MergeCommitSha = mergeCommitSha;
|
|
Comments = comments;
|
|
Commits = commits;
|
|
Additions = additions;
|
|
Deletions = deletions;
|
|
ChangedFiles = changedFiles;
|
|
Milestone = milestone;
|
|
Locked = locked;
|
|
RequestedReviewers = requestedReviewers;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The internal Id for this pull request (not the pull request number)
|
|
/// </summary>
|
|
public long Id { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for this pull request.
|
|
/// </summary>
|
|
public string Url { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for the pull request page.
|
|
/// </summary>
|
|
public string HtmlUrl { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for the pull request's diff (.diff) file.
|
|
/// </summary>
|
|
public string DiffUrl { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for the pull request's patch (.patch) file.
|
|
/// </summary>
|
|
public string PatchUrl { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for the specific pull request issue.
|
|
/// </summary>
|
|
public string IssueUrl { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The URL for the pull request statuses.
|
|
/// </summary>
|
|
public string StatusesUrl { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The pull request number.
|
|
/// </summary>
|
|
public int Number { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Whether the pull request is open or closed. The default is <see cref="ItemState.Open"/>.
|
|
/// </summary>
|
|
public StringEnum<ItemState> State { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Title of the pull request.
|
|
/// </summary>
|
|
public string Title { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The body (content) contained within the pull request.
|
|
/// </summary>
|
|
public string Body { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// When the pull request was created.
|
|
/// </summary>
|
|
public DateTimeOffset CreatedAt { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// When the pull request was last updated.
|
|
/// </summary>
|
|
public DateTimeOffset UpdatedAt { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// When the pull request was closed.
|
|
/// </summary>
|
|
public DateTimeOffset? ClosedAt { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// When the pull request was merged.
|
|
/// </summary>
|
|
public DateTimeOffset? MergedAt { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The HEAD reference for the pull request.
|
|
/// </summary>
|
|
public GitReference Head { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The BASE reference for the pull request.
|
|
/// </summary>
|
|
public GitReference Base { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The user who created the pull request.
|
|
/// </summary>
|
|
public User User { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The user who is assigned the pull request.
|
|
/// </summary>
|
|
public User Assignee { get; protected set; }
|
|
|
|
/// <summary>
|
|
///The multiple users this pull request is assigned to.
|
|
/// </summary>
|
|
public IReadOnlyList<User> Assignees { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The milestone, if any, that this pull request is assigned to.
|
|
/// </summary>
|
|
public Milestone Milestone { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Whether or not the pull request has been merged.
|
|
/// </summary>
|
|
public bool Merged
|
|
{
|
|
get { return MergedAt.HasValue; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Whether or not the pull request can be merged.
|
|
/// </summary>
|
|
public bool? Mergeable { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The user who merged the pull request.
|
|
/// </summary>
|
|
public User MergedBy { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// The value of this field changes depending on the state of the pull request.
|
|
/// Not Merged - the hash of the test commit used to determine mergability.
|
|
/// Merged with merge commit - the hash of said merge commit.
|
|
/// Merged via squashing - the hash of the squashed commit added to the base branch.
|
|
/// Merged via rebase - the hash of the commit that the base branch was updated to.
|
|
/// </summary>
|
|
public string MergeCommitSha { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Total number of comments contained in the pull request.
|
|
/// </summary>
|
|
public int Comments { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Total number of commits contained in the pull request.
|
|
/// </summary>
|
|
public int Commits { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Total number of additions contained in the pull request.
|
|
/// </summary>
|
|
public int Additions { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Total number of deletions contained in the pull request.
|
|
/// </summary>
|
|
public int Deletions { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Total number of files changed in the pull request.
|
|
/// </summary>
|
|
public int ChangedFiles { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// If the issue is locked or not
|
|
/// </summary>
|
|
public bool Locked { get; protected set; }
|
|
|
|
/// <summary>
|
|
/// Users requested for review
|
|
/// </summary>
|
|
public IReadOnlyList<User> RequestedReviewers { get; protected set; }
|
|
|
|
internal string DebuggerDisplay
|
|
{
|
|
get { return string.Format(CultureInfo.InvariantCulture, "Number: {0} State: {1}", Number, State); }
|
|
}
|
|
}
|
|
}
|