Skip to content

Commit

Permalink
add new types for webhook commit payload (#1844)
Browse files Browse the repository at this point in the history
Co-authored-by: Itai Bar-Haim <[email protected]>
  • Loading branch information
itaibh and itaibh authored Feb 24, 2020
1 parent fe6639f commit 6fdd800
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Octokit/Models/Response/ActivityPayloads/PushWebhookCommit.cs
Original file line number Diff line number Diff line change
@@ -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<string> Added { get; protected set; }

public IReadOnlyList<string> Removed { get; protected set; }

public IReadOnlyList<string> Modified { get; protected set; }

internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Sha: {0}", Id);
}
}
}
}
61 changes: 61 additions & 0 deletions Octokit/Models/Response/ActivityPayloads/PushWebhookCommitter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Diagnostics;
using System.Globalization;

namespace Octokit
{
/// <summary>
/// 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.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class PushWebhookCommitter
{
/// <summary>
/// Initializes a new instance of the <see cref="PushWebhookCommitter"/> class.
/// </summary>
public PushWebhookCommitter() { }

/// <summary>
/// Initializes a new instance of the <see cref="PushWebhookCommitter"/> class.
/// </summary>
/// <param name="name">The full name of the author or committer.</param>
/// <param name="email">The email.</param>
/// <param name="username">The username associated with the account.</param>
public PushWebhookCommitter(string name, string email, string username)
{
Name = name;
Email = email;
Username = username;
}

/// <summary>
/// Gets the name of the author or committer.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; protected set; }

/// <summary>
/// Gets the email of the author or committer.
/// </summary>
/// <value>
/// The email.
/// </value>
public string Email { get; protected set; }

/// <summary>
/// Gets the GitHub username associated with the commit
/// </summary>
/// <value>
/// The username.
/// </value>
public string Username { get; protected set; }

internal string DebuggerDisplay
{
get { return string.Format(CultureInfo.InvariantCulture, "Name: {0} Email: {1} Username: {2}", Name, Email, Username); }
}
}
}
22 changes: 22 additions & 0 deletions Octokit/Models/Response/ActivityPayloads/PushWebhookPayload.cs
Original file line number Diff line number Diff line change
@@ -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<PushWebhookCommit> Commits { get; protected set; }
public PushWebhookCommit HeadCommit { get; protected set; }
}
}

0 comments on commit 6fdd800

Please sign in to comment.