Search in sources :

Example 6 with GitProjectData

use of org.eclipse.egit.core.project.GitProjectData 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)

Example 7 with GitProjectData

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

the class DynamicVariablesTest method setUp.

@Before
public void setUp() throws Exception {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    FileUtils.mkdir(new File(root.getLocation().toFile(), "Sub"), true);
    gitDir = new File(new File(root.getLocation().toFile(), "Sub"), Constants.DOT_GIT);
    repository = FileRepositoryBuilder.create(gitDir);
    repository.create();
    project = root.getProject(TEST_PROJECT);
    project.create(null);
    project.open(null);
    IProjectDescription description = project.getDescription();
    description.setLocation(root.getLocation().append(TEST_PROJECT_LOC));
    project.move(description, IResource.FORCE, null);
    project2 = root.getProject(TEST_PROJECT2);
    project2.create(null);
    project2.open(null);
    gitDir2 = new File(project2.getLocation().toFile().getAbsoluteFile(), Constants.DOT_GIT);
    repository2 = FileRepositoryBuilder.create(gitDir2);
    repository2.create();
    RepositoryMapping mapping = RepositoryMapping.create(project, gitDir);
    RepositoryMapping mapping2 = RepositoryMapping.create(project2, gitDir2);
    GitProjectData projectData = new GitProjectData(project);
    GitProjectData projectData2 = new GitProjectData(project2);
    projectData.setRepositoryMappings(Collections.singletonList(mapping));
    projectData.store();
    projectData2.setRepositoryMappings(Collections.singletonList(mapping2));
    projectData2.store();
    GitProjectData.add(project, projectData);
    GitProjectData.add(project2, projectData2);
    RepositoryProvider.map(project, GitProvider.class.getName());
    RepositoryProvider.map(project2, GitProvider.class.getName());
    JGitTestUtil.write(new File(repository.getWorkTree(), TEST_PROJECT + "/" + TEST_FILE), "Some data");
    JGitTestUtil.write(new File(repository2.getWorkTree(), TEST_FILE2), "Some other data");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    project2.refreshLocal(IResource.DEPTH_INFINITE, null);
    git = new Git(repository);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();
    git = new Git(repository2);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();
    git.branchRename().setNewName("main").call();
}
Also used : Git(org.eclipse.jgit.api.Git) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IProjectDescription(org.eclipse.core.resources.IProjectDescription) RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) File(java.io.File) GitProjectData(org.eclipse.egit.core.project.GitProjectData) GitProvider(org.eclipse.egit.core.GitProvider) Before(org.junit.Before)

Example 8 with GitProjectData

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

the class GitMoveDeleteHook method mapProject.

private void mapProject(final IProject source, final IProjectDescription description, final IProgressMonitor monitor, IPath gitDir) throws CoreException, TeamException {
    IProject destination = source.getWorkspace().getRoot().getProject(description.getName());
    RepositoryMapping repositoryMapping = RepositoryMapping.create(destination, gitDir.toFile());
    if (repositoryMapping != null) {
        GitProjectData projectData = new GitProjectData(destination);
        projectData.setRepositoryMappings(Arrays.asList(repositoryMapping));
        projectData.store();
        GitProjectData.add(destination, projectData);
        RepositoryProvider.map(destination, GitProvider.class.getName());
        destination.refreshLocal(IResource.DEPTH_INFINITE, monitor);
    }
}
Also used : RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) GitProjectData(org.eclipse.egit.core.project.GitProjectData) IProject(org.eclipse.core.resources.IProject)

Example 9 with GitProjectData

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

the class AssumeUnchangedOperation method assumeValid.

private void assumeValid(final IResource resource) throws CoreException {
    final IProject proj = resource.getProject();
    if (proj == null) {
        return;
    }
    final GitProjectData pd = GitProjectData.get(proj);
    if (pd == null) {
        return;
    }
    final RepositoryMapping rm = pd.getRepositoryMapping(resource);
    if (rm == null) {
        return;
    }
    this.db = rm.getRepository();
    assumeValid(resource.getLocation());
}
Also used : RepositoryMapping(org.eclipse.egit.core.project.RepositoryMapping) GitProjectData(org.eclipse.egit.core.project.GitProjectData) IProject(org.eclipse.core.resources.IProject)

Aggregations

GitProjectData (org.eclipse.egit.core.project.GitProjectData)9 RepositoryMapping (org.eclipse.egit.core.project.RepositoryMapping)9 IProject (org.eclipse.core.resources.IProject)4 IPath (org.eclipse.core.runtime.IPath)4 GitProvider (org.eclipse.egit.core.GitProvider)3 Repository (org.eclipse.jgit.lib.Repository)3 File (java.io.File)1 IOException (java.io.IOException)1 IContainer (org.eclipse.core.resources.IContainer)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 IResource (org.eclipse.core.resources.IResource)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IndexDiffCacheEntry (org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry)1 RepositoryFinder (org.eclipse.egit.core.project.RepositoryFinder)1 Git (org.eclipse.jgit.api.Git)1 StoredConfig (org.eclipse.jgit.lib.StoredConfig)1 RepositoryProvider (org.eclipse.team.core.RepositoryProvider)1