using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; namespace Octokit { /// /// Used to create a commit. /// /// /// API: https://developer.github.com/v3/git/commits/#create-a-commit /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public class NewCommit { /// /// Create a new commit which has multiple parents (i.e. a merge commit) /// /// The message to associate with the commit /// The tree associated with the commit /// /// The SHAs of the commits that were the parents of this commit. If empty, the commit will be written as a /// root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of /// more than one should be provided. /// public NewCommit(string message, string tree, IEnumerable parents) { Message = message; Tree = tree; Parents = parents; } /// /// Create a new commit which does not have any parents /// /// The message to associate with the commit /// The tree associated with the commit public NewCommit(string message, string tree) : this(message, tree, Enumerable.Empty()) { } /// /// Create a new commit which has one parent /// /// The message to associate with the commit /// The tree associated with the commit /// The commit to use as a parent public NewCommit(string message, string tree, string parent) : this(message, tree, new[] { parent }) { } /// /// Gets the commit message. /// /// /// The message. /// public string Message { get; private set; } /// /// Gets the tree associated with the commit. /// /// /// The tree. /// public string Tree { get; private set; } /// /// Gets the SHAs of the commits that were the parents of this commit. If empty, the commit will be written as /// a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of /// more than one should be provided. /// /// /// The parents. /// public IEnumerable Parents { get; private set; } /// /// Gets or sets the author of the commit. If omitted, it will be filled in with the authenticated user’s /// information and the current date. /// /// /// The author. /// public Committer Author { get; set; } /// /// Gets or sets the person who applied the commit. If omitted, this will be filled in with the /// . /// /// /// The committer. /// public Committer Committer { get; set; } internal string DebuggerDisplay { get { return string.Format(CultureInfo.InvariantCulture, "Message: {0}", Message); } } } }