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;
}
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();
}
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);
}
}
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());
}
Aggregations