private void AddCommitFiles(List <LibGit2Sharp.Commit> commits) { int i = 0; double count = commits.Count(); foreach (var c in commits) { this.FireProgressChanged(i++ / count); i++; if (c.Parents.Any()) { foreach (var p in c.Parents) { foreach (var change in Repo.Diff.Compare <TreeChanges>(p.Tree, c.Tree)) { // generate for changed file in current commit if (change.Exists) { { var fileSearch = new File() { Path = change.Path, Commit = c.Sha }; if (neo4jwrapp.Find <File>(fileSearch).Any()) { continue; } } var fileNode = new File(this.neo4jwrapp) { Path = change.Path, Commit = c.Sha }; this.neo4jwrapp.WriteNode(fileNode); switch (change.Status) { case ChangeKind.Modified: this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new ModifiedFile(this.neo4jwrapp) { ChangeParrentCommit = p.Sha }, new ContainsFile(this.neo4jwrapp)); break; case ChangeKind.Renamed: this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new RenamedFile(this.neo4jwrapp), new ContainsFile(this.neo4jwrapp)); break; case ChangeKind.Added: this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new CreatedFile(this.neo4jwrapp), new ContainsFile(this.neo4jwrapp)); break; default: int useForBreakPoint = 0; this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new ModifiedFile(this.neo4jwrapp) { ChangeParrentCommit = p.Sha }, new ContainsFile(this.neo4jwrapp)); break; } } else { switch (change.Status) { case ChangeKind.Deleted: { // Do nothing ... will later create an edge to the deleted file node } break; default: int useForBreakPoint = 0; break; } } } } // add no modification nodes to create complete change history foreach (var element in CommitAnalyzser.GetAllLeafesInTree(c.Tree)) { { var fileSearch = new File() { Path = element.Path, Commit = c.Sha }; if (neo4jwrapp.Find <BaseNode>(fileSearch).Any()) { continue; } } var fileNode = new File(this.neo4jwrapp) { Path = element.Path, Commit = c.Sha }; this.neo4jwrapp.WriteNode(fileNode); this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new NoModification(this.neo4jwrapp), new ContainsFile(this.neo4jwrapp)); } } else { // do initial commit foreach (var element in CommitAnalyzser.GetAllLeafesInTree(c.Tree)) { { var fileSearch = new File() { Path = element.Path, Commit = c.Sha }; if (neo4jwrapp.Find <BaseNode>(fileSearch).Any()) { continue; } } var fileNode = new File(this.neo4jwrapp) { Path = element.Path, Commit = c.Sha }; this.neo4jwrapp.WriteNode(fileNode); this.neo4jwrapp.WriteEdge(new GraphClasses.Node.Commit(null) { Sha = c.Sha }, fileNode, new CreatedFile(this.neo4jwrapp), new ContainsFile(this.neo4jwrapp)); } } } }
private string GetRaw(string commitSha, string path) { var commit = Repo.Commits.FirstOrDefault(c => c.Sha == commitSha); return(CommitAnalyzser.StreamToString(CommitAnalyzser.ContentStreamFromPath(commit, path))); }