Search in sources :

Example 1 with ConfigureFetchAfterCloneTask

use of org.eclipse.egit.core.op.ConfigureFetchAfterCloneTask in project egit by eclipse.

the class CloneOperationTest method testConfigureFetchAfterCloneTask.

@Test
public void testConfigureFetchAfterCloneTask() throws Exception {
    createNoteInOrigin();
    URIish uri = new URIish("file:///" + repository1.getRepository().getDirectory().toString());
    CloneOperation clop = new CloneOperation(uri, true, null, workdir2, "refs/heads/master", "origin", 0);
    clop.addPostCloneTask(new ConfigureFetchAfterCloneTask("origin", "refs/notes/review:refs/notes/review"));
    clop.run(null);
    Repository clonedRepo = FileRepositoryBuilder.create(new File(workdir2, Constants.DOT_GIT));
    assertTrue(clonedRepo.getConfig().getStringList(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "fetch")[1].equals("refs/notes/review:refs/notes/review"));
    Git clonedGit = new Git(clonedRepo);
    assertEquals(1, clonedGit.notesList().setNotesRef("refs/notes/review").call().size());
    clonedGit.close();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) TestRepository(org.eclipse.egit.core.test.TestRepository) Repository(org.eclipse.jgit.lib.Repository) Git(org.eclipse.jgit.api.Git) ConfigureFetchAfterCloneTask(org.eclipse.egit.core.op.ConfigureFetchAfterCloneTask) File(java.io.File) CloneOperation(org.eclipse.egit.core.op.CloneOperation) Test(org.junit.Test)

Aggregations

File (java.io.File)1 CloneOperation (org.eclipse.egit.core.op.CloneOperation)1 ConfigureFetchAfterCloneTask (org.eclipse.egit.core.op.ConfigureFetchAfterCloneTask)1 TestRepository (org.eclipse.egit.core.test.TestRepository)1 Git (org.eclipse.jgit.api.Git)1 Repository (org.eclipse.jgit.lib.Repository)1 URIish (org.eclipse.jgit.transport.URIish)1 Test (org.junit.Test)1