Created
December 30, 2012 14:27
-
-
Save owickstrom/4413032 to your computer and use it in GitHub Desktop.
Possible solution (not tested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual IEnumerable<Commit> GetFromTo(DateTime start, DateTime end) | |
{ | |
this.ThrowWhenDisposed(); | |
Logger.Debug(Resources.GettingAllCommitsFromToTime, start, end); | |
var selectedCommitIds = this.stamps.Where(x => x.Value >= start && x.Value < end).Select(x => x.Key); | |
var firstCommitId = selectedCommitIds.FirstOrDefault(); | |
var lastCommitId = selectedCommitIds.LastOrDefault(); | |
if (lastCommitId == Guid.Empty && lastCommitId == Guid.Empty) | |
return new Commit[] { }; | |
var startingCommit = this.commits.FirstOrDefault(x => x.CommitId == firstCommitId); | |
var endingCommit = this.commits.FirstOrDefault(x => x.CommitId == lastCommitId); | |
var startingCommitIndex = (startingCommit == null) ? 0 : this.commits.IndexOf(startingCommit); | |
var endingCommitIndex = (endingCommit == null) ? this.commits.Count - 1 : this.commits.IndexOf(endingCommit); | |
var numberToTake = endingCommitIndex - startingCommitIndex + 1; | |
return this.commits.Skip(this.commits.IndexOf(startingCommit)).Take(numberToTake); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment