using System.Collections; using System.Collections.Generic; using System.Linq; namespace LibGit2Sharp { /// /// Criterias used to filter out and order the commits of the repository when querying its history. /// public sealed class CommitFilter { /// /// Initializes a new instance of . /// public CommitFilter() { SortBy = CommitSortStrategies.Time; Since = "HEAD"; FirstParentOnly = false; } /// /// The ordering stragtegy to use. /// /// By default, the commits are shown in reverse chronological order. /// /// public CommitSortStrategies SortBy { get; set; } /// /// A pointer to a commit object or a list of pointers to consider as starting points. /// /// Can be either a containing the sha or reference canonical name to use, /// a , a , a , a , /// a , an or even a mixed collection of all of the above. /// By default, the will be used as boundary. /// /// public object Since { get; set; } internal IList SinceList { get { return ToList(Since); } } /// /// A pointer to a commit object or a list of pointers which will be excluded (along with ancestors) from the enumeration. /// /// Can be either a containing the sha or reference canonical name to use, /// a , a , a , a , /// a , an or even a mixed collection of all of the above. /// /// public object Until { get; set; } internal IList UntilList { get { return ToList(Until); } } /// /// Whether to limit the walk to each commit's first parent, instead of all of them /// public bool FirstParentOnly { get; set; } private static IList ToList(object obj) { var list = new List(); if (obj == null) { return list; } var types = new[] { typeof(string), typeof(ObjectId), typeof(Commit), typeof(TagAnnotation), typeof(Tag), typeof(Branch), typeof(DetachedHead), typeof(Reference), typeof(DirectReference), typeof(SymbolicReference) }; if (types.Contains(obj.GetType())) { list.Add(obj); return list; } list.AddRange(((IEnumerable)obj).Cast()); return list; } } }