use of org.eclipse.egit.core.GitProvider 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.egit.core.GitProvider 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.egit.core.GitProvider 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());
}
use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class ResourceUtil method getGitProvider.
/**
* Returns git provider if associated with the given project or
* <code>null</code> if the project is not associated with a provider or the
* provider is not fully loaded yet. To check if the git provider is
* associated with the project, use {@link #isSharedWithGit(IResource)}.
*
* @param project
* the project to query for a provider
* @return the repository provider or null
*/
@Nullable
public static final GitProvider getGitProvider(@NonNull IProject project) {
if (!project.isAccessible()) {
return null;
}
try {
// Look for an existing provider
GitProvider provider = lookupProviderProp(project);
if (provider != null) {
return provider;
}
if (MappingJob.isKnownGitProject(project) || isMarkedAsNotSharedWithGit(project)) {
// isn't shared with us at all.
return null;
}
String existingID = project.getPersistentProperty(PROVIDER_PROP_KEY);
if (existingID == null) {
markAsUnshared(project);
} else {
markAsShared(project, existingID);
boolean isGitProvider = GitProvider.ID.equals(existingID);
if (isGitProvider) {
MappingJob.initProviderAsynchronously(project);
}
}
// or not a GitProvider
return null;
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
}
return null;
}
Aggregations