Search in sources :

Example 6 with GitProvider

use of org.eclipse.egit.core.GitProvider in project egit by eclipse.

the class HistoryTest method testSingleRevision_2.

@Test
public void testSingleRevision_2() {
    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("fd5a571c8a3a4a152e4c413d09d3ecb7d41e1e5f");
    // not matched by getFileHistoryFor
    assertNull(fileRevision);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 7 with GitProvider

use of org.eclipse.egit.core.GitProvider in project egit by eclipse.

the class HistoryTest method testIndexRevision.

@Test
public void testIndexRevision() 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/A.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("A.txt - first version\n", content);
}
Also used : IFileHistory(org.eclipse.team.core.history.IFileHistory) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFileHistoryProvider(org.eclipse.team.core.history.IFileHistoryProvider) IFileRevision(org.eclipse.team.core.history.IFileRevision) IStorage(org.eclipse.core.resources.IStorage) GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 8 with GitProvider

use of org.eclipse.egit.core.GitProvider in project egit by eclipse.

the class LinkedResourcesTest method testGitProviderCanHandleLinkedResources.

@Test
public void testGitProviderCanHandleLinkedResources() throws Exception {
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(project1);
    assertTrue(provider.canHandleLinkedResourceURI());
}
Also used : GitProvider(org.eclipse.egit.core.GitProvider) Test(org.junit.Test)

Example 9 with GitProvider

use of org.eclipse.egit.core.GitProvider in project jbosstools-openshift by jbosstools.

the class ResourceMocks method createGitSharedProject.

public static org.eclipse.core.resources.IProject createGitSharedProject(String name, String gitRemoteUri) throws CoreException {
    org.eclipse.core.resources.IProject project = createEclipseProject(name);
    when(project.getPersistentProperty(TeamPlugin.PROVIDER_PROP_KEY)).thenReturn(GitProvider.ID);
    when(project.getWorkingLocation(any())).thenReturn(new Path(ResourcesPlugin.getWorkspace().getRoot().getFullPath().toString()));
    StoredConfig config = mock(StoredConfig.class);
    when(config.getSubsections("remote")).thenReturn(new HashSet<String>(Arrays.asList("origin")));
    when(config.getStringList(any(), any(), any())).thenReturn(new String[] { gitRemoteUri });
    when(config.getStringList("remote", "origin", "url")).thenReturn(new String[] { gitRemoteUri });
    Repository repository = mock(Repository.class);
    when(repository.getConfig()).thenReturn(config);
    RepositoryMapping mapping = mock(RepositoryMapping.class);
    when(mapping.getRepository()).thenReturn(repository);
    GitProjectData data = mock(GitProjectData.class);
    when(data.getRepositoryMapping(project)).thenReturn(mapping);
    GitProvider repositoryProvider = mock(GitProvider.class);
    when(repositoryProvider.getID()).thenReturn(GitProvider.ID);
    when(repositoryProvider.getData()).thenReturn(data);
    when(project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY)).thenReturn(repositoryProvider);
    return project;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) StoredConfig(org.eclipse.jgit.lib.StoredConfig) Repository(org.eclipse.jgit.lib.Repository) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) Matchers.anyString(org.mockito.Matchers.anyString) GitProjectData(org.eclipse.egit.core.project.GitProjectData) GitProvider(org.eclipse.egit.core.GitProvider)

Example 10 with GitProvider

use of org.eclipse.egit.core.GitProvider in project egit by eclipse.

the class LocalRepositoryTestCase method assertConnected.

protected RepositoryMapping assertConnected(IProject project) {
    RepositoryProvider provider = RepositoryProvider.getProvider(project, GitProvider.ID);
    if (provider == null) {
        TestUtil.waitForJobs(5000, 10000);
        assertTrue("Project not shared with git: " + project, ResourceUtil.isSharedWithGit(project));
        TestUtil.waitForJobs(1000, 10000);
        provider = RepositoryProvider.getProvider(project);
    }
    assertTrue("Project is not accessible: " + project, project.isAccessible());
    assertNotNull("GitProvider not mapped to: " + project, provider);
    GitProjectData data = ((GitProvider) provider).getData();
    if (data == null) {
        TestUtil.waitForJobs(100, 5000);
        data = ((GitProvider) provider).getData();
    }
    assertNotNull("GitProjectData is null for: " + project, data);
    RepositoryMapping mapping = data.getRepositoryMapping(project);
    if (mapping == null) {
        TestUtil.waitForJobs(100, 5000);
        mapping = data.getRepositoryMapping(project);
    }
    assertNotNull("RepositoryMapping is null for: " + project, mapping);
    return mapping;
}
Also used : RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) RepositoryProvider(org.eclipse.team.core.RepositoryProvider) GitProjectData(org.eclipse.egit.core.project.GitProjectData) GitProvider(org.eclipse.egit.core.GitProvider)

Aggregations

GitProvider (org.eclipse.egit.core.GitProvider)14 Test (org.junit.Test)9 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 IFileHistory (org.eclipse.team.core.history.IFileHistory)8 IFileHistoryProvider (org.eclipse.team.core.history.IFileHistoryProvider)8 IFileRevision (org.eclipse.team.core.history.IFileRevision)8 IStorage (org.eclipse.core.resources.IStorage)2 CoreException (org.eclipse.core.runtime.CoreException)2 GitProjectData (org.eclipse.egit.core.project.GitProjectData)2 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)2 Nullable (org.eclipse.jgit.annotations.Nullable)2 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 Repository (org.eclipse.jgit.lib.Repository)1 StoredConfig (org.eclipse.jgit.lib.StoredConfig)1 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)1 Matchers.anyString (org.mockito.Matchers.anyString)1