use of org.eclipse.team.core.history.IFileHistoryProvider in project pmd-eclipse-plugin by pmd.
the class RepositoryUtil method authorNameFor.
/**
* Returns the name of the resource author if the resource was parked in a
* repository or null if it wasn't.
*
* @param resource
* @return String
*/
public static String authorNameFor(IResource resource) {
IProject project = resource.getProject();
String authorName = null;
try {
RepositoryProvider provider = RepositoryProvider.getProvider(project);
if (provider == null) {
return null;
}
IFileHistoryProvider fhProvider = provider.getFileHistoryProvider();
if (fhProvider == null) {
return null;
}
IFileRevision revision = fhProvider.getWorkspaceFileRevision(resource);
authorName = revision.getAuthor();
} catch (Exception ex) {
ex.printStackTrace();
}
return authorName;
}
use of org.eclipse.team.core.history.IFileHistoryProvider in project egit by eclipse.
the class HistoryTest method testDeepHistory_B.
@Test
public void testDeepHistory_B() {
GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
assertNotNull(provider);
IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/B.txt"), IFileHistoryProvider.NONE, new NullProgressMonitor());
IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
assertEquals(2, fileRevisions.length);
assertEquals("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f", fileRevisions[0].getContentIdentifier());
assertEquals("J. Author", fileRevisions[0].getAuthor());
assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[1].getContentIdentifier());
assertEquals("J. Author", fileRevisions[0].getAuthor());
}
use of org.eclipse.team.core.history.IFileHistoryProvider in project egit by eclipse.
the class HistoryTest method testSingleRevision_3.
@Test
public void testSingleRevision_3() {
GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
assertNotNull(provider);
IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/B.txt"), IFileHistoryProvider.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
IFileRevision fileRevision = fileHistory.getFileRevision("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f");
assertEquals("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f", fileRevision.getContentIdentifier());
assertEquals("J. Author", fileRevision.getAuthor());
}
use of org.eclipse.team.core.history.IFileHistoryProvider in project egit by eclipse.
the class HistoryTest method testDeepHistory_A.
@Test
public void testDeepHistory_A() {
GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project.project);
assertNotNull(provider);
IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
IFileHistory fileHistory = fileHistoryProvider.getFileHistoryFor(project.getProject().getWorkspace().getRoot().findMember("Project-1/A.txt"), IFileHistoryProvider.NONE, new NullProgressMonitor());
IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
assertEquals(1, fileRevisions.length);
assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[0].getContentIdentifier());
assertEquals("J. Author", fileRevisions[0].getAuthor());
}
Aggregations