RevCommit[] GetBlameForFile(string revision, string filePath) { RevCommit[] blame; string path = PROJECT_ROOT + filePath; string key = path + revision; blames.TryGetValue(key, out blame); if (blame == null) { var git = new NGit.Api.Git(repo); var commit = git.GetRepository().Resolve(revision); var result = git.Blame().SetFilePath(filePath).SetStartCommit(commit).Call(); if (result == null) { return(null); } blame = new RevCommit [result.GetResultContents().Size()]; for (int i = 0; i < result.GetResultContents().Size(); i++) { blame [i] = result.GetSourceCommit(i); } blames.Add(key, blame); } return(blame); }
RevCommit[] GetBlameForFile (string revision, string filePath) { RevCommit[] blame = null; string path = PROJECT_ROOT + filePath; string key = path + revision; blames.TryGetValue(key, out blame); if (blame == null) { var git = new NGit.Api.Git (repo); var commit = git.GetRepository ().Resolve (revision); var result = git.Blame ().SetFilePath (filePath).SetStartCommit (commit).Call (); if (result == null) return null; blame = new RevCommit [result.GetResultContents ().Size ()]; for (int i = 0; i < result.GetResultContents ().Size (); i ++) blame [i] = result.GetSourceCommit (i); blames.Add(key, blame); } return blame; }