From 6fdd800f729c40c9b9cfa7cd71e49b75dbce1ad9 Mon Sep 17 00:00:00 2001 From: Itai Bar-Haim Date: Mon, 24 Feb 2020 19:37:03 +0200 Subject: [PATCH] add new types for webhook commit payload (#1844) Co-authored-by: Itai Bar-Haim --- .../ActivityPayloads/PushWebhookCommit.cs | 41 +++++++++++++ .../ActivityPayloads/PushWebhookCommitter.cs | 61 +++++++++++++++++++ .../ActivityPayloads/PushWebhookPayload.cs | 22 +++++++ 3 files changed, 124 insertions(+) create mode 100644 Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs create mode 100644 Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs create mode 100644 Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs new file mode 100644 index 0000000000..6ce11053c8 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PushWebhookCommit + { + public string Id { get; protected set; } + + public string TreeId { get; protected set; } + + public bool Distinct { get; protected set; } + + public string Message { get; protected set; } + + public DateTimeOffset Timestamp { get; protected set; } + + public Uri Url { get; protected set; } + + public Committer Author { get; protected set; } + + public Committer Committer { get; protected set; } + + public IReadOnlyList Added { get; protected set; } + + public IReadOnlyList Removed { get; protected set; } + + public IReadOnlyList Modified { get; protected set; } + + internal string DebuggerDisplay + { + get + { + return string.Format(CultureInfo.InvariantCulture, "Sha: {0}", Id); + } + } + } +} diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs new file mode 100644 index 0000000000..f414a1b2b6 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs @@ -0,0 +1,61 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// + /// Represents the author or committer to a Git commit. This is the information stored in Git and should not be + /// confused with GitHub account information. + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PushWebhookCommitter + { + /// + /// Initializes a new instance of the class. + /// + public PushWebhookCommitter() { } + + /// + /// Initializes a new instance of the class. + /// + /// The full name of the author or committer. + /// The email. + /// The username associated with the account. + public PushWebhookCommitter(string name, string email, string username) + { + Name = name; + Email = email; + Username = username; + } + + /// + /// Gets the name of the author or committer. + /// + /// + /// The name. + /// + public string Name { get; protected set; } + + /// + /// Gets the email of the author or committer. + /// + /// + /// The email. + /// + public string Email { get; protected set; } + + /// + /// Gets the GitHub username associated with the commit + /// + /// + /// The username. + /// + public string Username { get; protected set; } + + internal string DebuggerDisplay + { + get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} Email: {1} Username: {2}", Name, Email, Username); } + } + } +} diff --git a/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs b/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs new file mode 100644 index 0000000000..159282de67 --- /dev/null +++ b/Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Diagnostics; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class PushWebhookPayload : ActivityPayload + { + public string Head { get; protected set; } + public string Before { get; protected set; } + public string After { get; protected set; } + public string Ref { get; protected set; } + public string BaseRef { get; protected set; } + public bool Created { get; protected set; } + public bool Deleted { get; protected set; } + public bool Forced { get; protected set; } + public string Compare { get; protected set; } + public int Size { get; protected set; } + public IReadOnlyList Commits { get; protected set; } + public PushWebhookCommit HeadCommit { get; protected set; } + } +}