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

CommitCollectionExtensions.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c0e5a6db8a3411c22b5669f22f04535da009fe96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Globalization;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
    public static class CommitCollectionExtensions
    {
        /// <summary>
        ///   Starts enumerating the <paramref name="commitCollection"/> at the specified branch.
        /// </summary>
        /// <param name="commitCollection">The commit collection to enumerate.</param>
        /// <param name = "branch">The branch.</param>
        /// <returns></returns>
        public static CommitCollection StartingAt(this CommitCollection commitCollection, Branch branch)
        {
            Ensure.ArgumentNotNull(branch, "branch");

            Commit commit = branch.Tip;

            if (commit == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "No valid object identified as '{0}' has been found in the repository.", branch.CanonicalName), "branch");
            }

            return commitCollection.StartingAt(commit.Sha);
        }

        /// <summary>
        ///   Starts enumerating the <paramref name="commitCollection"/> at the specified reference.
        /// </summary>
        /// <param name="commitCollection">The commit collection to enumerate.</param>
        /// <param name = "reference">The reference.</param>
        /// <returns></returns>
        public static CommitCollection StartingAt(this CommitCollection commitCollection, Reference reference)
        {
            Ensure.ArgumentNotNull(reference, "reference");

            return commitCollection.StartingAt(reference.ResolveToDirectReference().CanonicalName);
        }
    }
}