public static int GetHeight(LibGit2Context context, Func <Commit, bool>?continueStepping = null)
        {
            Verify.Operation(context.Commit is object, "No commit is selected.");
            var tracker = new GitWalkTracker(context);

            return(GetCommitHeight(context.Commit, tracker, continueStepping));
        }
        internal static int GetVersionHeight(LibGit2Context context, Version?baseVersion = null)
        {
            if (context.Commit is null)
            {
                return(0);
            }

            var tracker = new GitWalkTracker(context);

            var versionOptions = tracker.GetVersion(context.Commit);

            if (versionOptions is null)
            {
                return(0);
            }

            var baseSemVer =
                baseVersion is not null?SemanticVersion.Parse(baseVersion.ToString()) :
                    versionOptions.Version ?? SemVer0;

            var versionHeightPosition = versionOptions.VersionHeightPosition;

            if (versionHeightPosition.HasValue)
            {
                int height = GetHeight(context, c => CommitMatchesVersion(c, baseSemVer, versionHeightPosition.Value, tracker));
                return(height);
            }

            return(0);
        }
        public static IEnumerable <Commit> GetCommitsFromVersion(LibGit2Context context, Version version)
        {
            Requires.NotNull(context, nameof(context));
            Requires.NotNull(version, nameof(version));

            var tracker         = new GitWalkTracker(context);
            var possibleCommits = from commit in GetCommitsReachableFromRefs(context.Repository)
                                  let commitVersionOptions = tracker.GetVersion(commit)
                                                             where commitVersionOptions?.Version?.IsMatchingVersion(version) is true
                                                             where !IsCommitIdMismatch(version, commitVersionOptions, commit)
                                                             where !IsVersionHeightMismatch(version, commitVersionOptions, commit, tracker)
                                                             select commit;

            return(possibleCommits);
        }
 internal LibGit2VersionFile(LibGit2Context context)
     : base(context)
 {
 }
 internal GitWalkTracker(LibGit2Context context)
 {
     this.context = context;
 }
 public static Commit GetCommitFromVersion(LibGit2Context context, Version version)
 {
     // Note we'll accept no match, or one match. But we throw if there is more than one match.
     return(GetCommitsFromVersion(context, version).SingleOrDefault());
 }