public CommitInformation(Commit commit, IInterestedContentExtractingStrategy strategy) { this.authorEmail = commit.Author.EmailAddress; this.committerEmail = commit.Committer.EmailAddress; this.commitDate = commit.CommitDate; this.strategy = strategy; this.sourceFileChanges = GetSourceChanges(commit, strategy); }
private static IEnumerable<CommitInformation> AnalyzeRevisionHistory(Commit head, IInterestedContentExtractingStrategy strategy) { var commitInfors = new List<CommitInformation>(); // Translate every commit to a commit information and add them to the list. for (; head != null; head = head.Parent) { var infor = new CommitInformation(head, strategy); if(infor.HasInterestedContent()) { commitInfors.Insert(0, infor); }; } return commitInfors; }
private List<SourceFileChange> GetSourceChanges(Commit commit, IInterestedContentExtractingStrategy strategy) { var sourceChanges = new List<SourceFileChange>(); // Get the changes that are changing the C# source code. var changes = commit.Changes.Where(c => c.Name.EndsWith(".cs") && c.ChangedObject.IsBlob); if (changes.Any()) { // For each change in the found changes. foreach (var change in changes) { // Get the file name of where the change is performed on. string fileName = change.Name; // Get the source after change. string source = ((Blob)change.ChangedObject).Data; // Get the interested content from the source code. var interestedContent = strategy.GetInterestedContent(source); if (strategy.HasInterestedContent(interestedContent)) { sourceChanges.Add(new SourceFileChange() { fileName = fileName, interestedContents = strategy.GetInterestedContent(source) }); } } } return sourceChanges; }