use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ShowBlameActionHandlerTest method createJavaProjectAndCommitToRepository.
private IJavaProject createJavaProjectAndCommitToRepository() throws Exception {
Repository myRepository = createLocalTestRepository(REPO1);
File gitDir = myRepository.getDirectory();
IJavaProject jProject = createJavaProject(myRepository, JAVA_PROJECT_NAME);
IProject project = jProject.getProject();
try {
new ConnectProviderOperation(project, gitDir).execute(null);
} catch (Exception e) {
Activator.logError("Failed to connect project to repository", e);
}
assertConnected(project);
// Check in at least the java file
IFolder folder = project.getFolder(SRC_FOLDER_NAME).getFolder(PACKAGE_NAME);
IFile file = folder.getFile(JAVA_FILE_NAME);
IFile[] commitables = new IFile[] { file };
ArrayList<IFile> untracked = new ArrayList<IFile>();
untracked.addAll(Arrays.asList(commitables));
// commit to master
CommitOperation op = new CommitOperation(commitables, untracked, TestUtil.TESTAUTHOR, TestUtil.TESTCOMMITTER, "Initial commit");
op.execute(null);
// Make sure cache entry is already listening for changes
IndexDiffCache cache = Activator.getDefault().getIndexDiffCache();
cache.getIndexDiffCacheEntry(lookupRepository(gitDir));
return jProject;
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class TestRepository method connect.
/**
* Connect a project to this repository
*
* @param project
* @throws Exception
*/
public void connect(IProject project) throws Exception {
ConnectProviderOperation op = new ConnectProviderOperation(project, this.getRepository().getDirectory());
op.execute(null);
TestUtils.waitForJobs(50, 5000, null);
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class HistoryTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
// ensure we are working on an empty repository
if (gitDir.exists())
FileUtils.delete(gitDir, FileUtils.RECURSIVE | FileUtils.RETRY);
thisGit = FileRepositoryBuilder.create(gitDir);
workDir = thisGit.getWorkTree();
thisGit.create();
try (Git git = new Git(thisGit)) {
createFile("Project-1/A.txt", "A.txt - first version\n");
createFile("Project-1/B.txt", "B.txt - first version\n");
git.add().addFilepattern("Project-1/A.txt").addFilepattern("Project-1/B.txt").call();
git.commit().setAuthor(jauthor).setCommitter(jcommitter).setMessage("Foo\n\nMessage").call();
createFile("Project-1/B.txt", "B.txt - second version\n");
git.add().addFilepattern("Project-1/B.txt").call();
git.commit().setAuthor(jauthor).setCommitter(jcommitter).setMessage("Modified").call();
}
ConnectProviderOperation operation = new ConnectProviderOperation(project.getProject(), gitDir);
operation.execute(null);
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ConnectProviderOperationTest method testAutoIgnoresDerivedFolder.
@Test
public void testAutoIgnoresDerivedFolder() throws Exception {
// enable auto-ignore
IEclipsePreferences p = InstanceScope.INSTANCE.getNode(Activator.getPluginId());
boolean autoignore = p.getBoolean(GitCorePreferences.core_autoIgnoreDerivedResources, false);
if (!autoignore) {
p.putBoolean(GitCorePreferences.core_autoIgnoreDerivedResources, true);
}
try {
Repository repository = FileRepositoryBuilder.create(gitDir);
repository.create();
repository.close();
project.setBinFolderDerived();
project.createSourceFolder();
// not connected: no ignore
IFolder binFolder = project.getProject().getFolder("bin");
IPath binPath = binFolder.getLocation();
assertTrue(binFolder.exists());
assertFalse(RepositoryUtil.canBeAutoIgnored(binPath));
IFolder srcFolder = project.getProject().getFolder("src");
IPath srcPath = srcFolder.getLocation();
assertTrue(srcFolder.exists());
assertFalse(RepositoryUtil.canBeAutoIgnored(srcPath));
IFolder notThere = project.getProject().getFolder("notThere");
IPath notTherePath = notThere.getLocation();
assertFalse(notThere.exists());
assertFalse(RepositoryUtil.canBeAutoIgnored(notTherePath));
// connect to git
ConnectProviderOperation operation = new ConnectProviderOperation(project.getProject(), gitDir);
operation.execute(null);
assertTrue(RepositoryProvider.isShared(project.getProject()));
Job.getJobManager().join(JobFamilies.AUTO_IGNORE, null);
// connected, and already automatically ignored
assertFalse(RepositoryUtil.canBeAutoIgnored(binPath));
// connected, and *can* be automatically ignored
assertTrue(RepositoryUtil.canBeAutoIgnored(srcPath));
// connected but not existing: we should not autoignore
assertFalse(RepositoryUtil.canBeAutoIgnored(notTherePath));
assertTrue(gitDir.exists());
} finally {
if (!autoignore) {
p.putBoolean(GitCorePreferences.core_autoIgnoreDerivedResources, false);
}
}
}
use of org.eclipse.egit.core.op.ConnectProviderOperation in project egit by eclipse.
the class ConnectProviderOperationTest method testNoRepository.
@Test
public void testNoRepository() throws Exception {
ConnectProviderOperation operation = new ConnectProviderOperation(project.getProject(), new File("../..", Constants.DOT_GIT));
try {
operation.execute(null);
Assert.fail("Connect without repository should fail!");
} catch (CoreException e) {
// expected
}
assertFalse(RepositoryProvider.isShared(project.getProject()));
assertFalse(gitDir.exists());
}
Aggregations