use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class ResourceUtil method isSharedWithGit.
/**
* @param resource
* non null
* @return true if the project is configured with git provider
*/
public static boolean isSharedWithGit(@NonNull IResource resource) {
IProject project = resource.getProject();
if (project == null || !project.isAccessible()) {
return false;
}
try {
// Look for an existing provider
GitProvider provider = lookupProviderProp(project);
if (provider != null || MappingJob.isKnownGitProject(project)) {
// Is mapped or in the process of being mapped.
return true;
} else if (isMarkedAsNotSharedWithGit(project)) {
return false;
}
// There isn't one so check the persistent property
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);
}
return isGitProvider;
} catch (CoreException e) {
Activator.getDefault().getLog().log(e.getStatus());
return false;
}
}
use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class RepositoryMapping method getProjectData.
/**
* Get the git project data for a project.
*
* @param project
* to find the data for
* @return the git project data for this project, or null for non
* GitProvider.
*/
@Nullable
private static GitProjectData getProjectData(@Nullable final IProject project) {
if (project == null || isNonWorkspace(project)) {
return null;
}
final GitProvider rp = ResourceUtil.getGitProvider(project);
GitProjectData data;
// The provider could not yet be mapped
if (rp == null) {
// Load the data directly
data = GitProjectData.get(project);
if (data == null) {
return null;
}
} else {
data = rp.getData();
}
return data;
}
use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class HistoryTest method testSingleRevision_1.
@Test
public void testSingleRevision_1() {
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.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
IFileRevision fileRevision = fileHistory.getFileRevision("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359");
assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevision.getContentIdentifier());
assertEquals("J. Author", fileRevision.getAuthor());
}
use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class HistoryTest method testIndexRevisionSecondCommit.
@Test
public void testIndexRevisionSecondCommit() throws Exception {
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(GitFileRevision.INDEX);
assertEquals(GitFileRevision.INDEX, fileRevision.getContentIdentifier());
IStorage storage = fileRevision.getStorage(null);
String content = testUtils.slurpAndClose(storage.getContents());
assertEquals("B.txt - second version\n", content);
}
use of org.eclipse.egit.core.GitProvider in project egit by eclipse.
the class HistoryTest method testShallowHistory.
@Test
public void testShallowHistory() {
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.SINGLE_LINE_OF_DESCENT, new NullProgressMonitor());
IFileRevision[] fileRevisions = fileHistory.getFileRevisions();
assertEquals(1, fileRevisions.length);
assertEquals("60f0d7917fe2aed5c92b5bc35dfb55b9b8ada359", fileRevisions[0].getContentIdentifier());
assertEquals("J. Author", fileRevisions[0].getAuthor());
}
Aggregations