Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2013-06-26 17:05:51 +0400
committernulltoken <emeric.fermas@gmail.com>2013-06-28 22:16:57 +0400
commit7d9baab78e850ada6e88ef09c5b795793e7bd7b6 (patch)
tree1848b5fb747258fb9835966c338bf536ddf0829e /LibGit2Sharp/CommitFilter.cs
parent8dfa16f0ca2cbeba241a0373915f8314348b8a9b (diff)
Rename Filter into CommitFilter
Diffstat (limited to 'LibGit2Sharp/CommitFilter.cs')
-rw-r--r--LibGit2Sharp/CommitFilter.cs87
1 files changed, 87 insertions, 0 deletions
diff --git a/LibGit2Sharp/CommitFilter.cs b/LibGit2Sharp/CommitFilter.cs
new file mode 100644
index 00000000..8e26fbce
--- /dev/null
+++ b/LibGit2Sharp/CommitFilter.cs
@@ -0,0 +1,87 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace LibGit2Sharp
+{
+ /// <summary>
+ /// Criterias used to filter out and order the commits of the repository when querying its history.
+ /// </summary>
+ public class CommitFilter
+ {
+ /// <summary>
+ /// Initializes a new instance of <see cref = "LibGit2Sharp.Filter" />.
+ /// </summary>
+ public CommitFilter()
+ {
+ SortBy = GitSortOptions.Time;
+ Since = "HEAD";
+ }
+
+ /// <summary>
+ /// The ordering stragtegy to use.
+ /// <para>
+ /// By default, the commits are shown in reverse chronological order.
+ /// </para>
+ /// </summary>
+ public GitSortOptions SortBy { get; set; }
+
+ /// <summary>
+ /// A pointer to a commit object or a list of pointers to consider as starting points.
+ /// <para>
+ /// Can be either a <see cref = "string" /> containing the sha or reference canonical name to use,
+ /// a <see cref = "Branch" />, a <see cref = "Reference" />, a <see cref = "Commit" />, a <see cref = "Tag" />,
+ /// a <see cref = "TagAnnotation" />, an <see cref="ObjectId"/> or even a mixed collection of all of the above.
+ /// By default, the <see cref = "Repository.Head" /> will be used as boundary.
+ /// </para>
+ /// </summary>
+ public object Since { get; set; }
+
+ internal IList<object> SinceList
+ {
+ get { return ToList(Since); }
+ }
+
+ /// <summary>
+ /// A pointer to a commit object or a list of pointers which will be excluded (along with ancestors) from the enumeration.
+ /// <para>
+ /// Can be either a <see cref = "string" /> containing the sha or reference canonical name to use,
+ /// a <see cref = "Branch" />, a <see cref = "Reference" />, a <see cref = "Commit" />, a <see cref = "Tag" />,
+ /// a <see cref = "TagAnnotation" />, an <see cref="ObjectId"/> or even a mixed collection of all of the above.
+ /// </para>
+ /// </summary>
+ public object Until { get; set; }
+
+ internal IList<object> UntilList
+ {
+ get { return ToList(Until); }
+ }
+
+ private static IList<object> ToList(object obj)
+ {
+ var list = new List<object>();
+
+ 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<object>());
+ return list;
+ }
+ }
+}