Example usage for org.eclipse.jgit.lib Constants DOT_GIT

List of usage examples for org.eclipse.jgit.lib Constants DOT_GIT

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Constants DOT_GIT.

Prototype

String DOT_GIT

To view the source code for org.eclipse.jgit.lib Constants DOT_GIT.

Click Source Link

Document

Default name for the Git repository directory

Usage

From source file:org.eclipse.egit.core.test.LinkedResourcesTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    testUtils = new TestUtils();
    // Create first repo and project
    project1 = testUtils.createProjectInLocalFileSystem(project1Name);
    project1Dir = project1.getRawLocation().toFile();
    repository1 = new TestRepository(new File(project1Dir, Constants.DOT_GIT));
    testUtils.addFileToProject(project1, "project1folder1/project1folder1file1.txt", "Hello world");
    repository1.connect(project1);//from   www. j a v  a  2  s .  c  o m
    repository1.trackAllFiles(project1);
    repository1.commit("Initial commit");
    // Create 2nd repo and project
    project2 = testUtils.createProjectInLocalFileSystem(project2Name);
    project2Dir = project2.getRawLocation().toFile();
    repository2 = new TestRepository(new File(project2Dir, Constants.DOT_GIT));
    testUtils.addFileToProject(project2, "project2folder1/project2folder1file1.txt", "Hello world");
    repository2.connect(project2);
    repository2.trackAllFiles(project2);
    repository2.commit("Initial commit");
    // Set up git delta listener
    resourceDeltaTestHelper1 = new GitResourceDeltaTestHelper(repository1.getRepository());
    resourceDeltaTestHelper1.setUp();
    resourceDeltaTestHelper2 = new GitResourceDeltaTestHelper(repository2.getRepository());
    resourceDeltaTestHelper2.setUp();
}

From source file:org.eclipse.egit.core.test.MergeWithPreferredStrategyTest.java

License:Open Source License

/**
 * Sets the preference "preferred merge strategy" to "ours", so that the
 * MergeStrategy that will be used by any operation that needs a merge will
 * be the {@link MergeStrategy#OURS}./*from  w  w  w . j  a v a 2  s. c o m*/
 */
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    InstanceScope.INSTANCE.getNode(Activator.getPluginId()).put(GitCorePreferences.core_preferredMergeStrategy,
            "ours");
    gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());

    File file1 = testRepository.createFile(project.getProject(), "file1-1");
    testRepository.addAndCommit(project.getProject(), file1, "master commit 1");
    testRepository.createBranch(MASTER, SIDE);
    file2 = testRepository.createFile(project.getProject(), "file2");
    testRepository.appendFileContent(file2, "Content 2");
    testRepository.addAndCommit(project.getProject(), file2, "master commit 2");
    testRepository.checkoutBranch(SIDE);
    file3 = testRepository.createFile(project.getProject(), "file3");
    testRepository.appendFileContent(file3, "Content 3");
    testRepository.addAndCommit(project.getProject(), file3, "side commit 3");
    testRepository.checkoutBranch(MASTER);
}

From source file:org.eclipse.egit.core.test.op.AddOperationTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    super.setUp();
    gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());
}

From source file:org.eclipse.egit.core.test.op.CloneOperationTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    workdir = testUtils.createTempDir("Repository1");
    workdir2 = testUtils.createTempDir("Repository2");

    repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));

    File file = new File(workdir, "file1.txt");
    FileUtils.createNewFile(file);/*w w  w.jav  a  2 s.  c  om*/
    Git git = new Git(repository1.getRepository());
    git.add().addFilepattern("file1.txt").call();

    git.commit().setMessage("first commit").call();
}

From source file:org.eclipse.egit.core.test.op.CloneOperationTest.java

License:Open Source License

@Test
public void testClone() throws Exception {
    URIish uri = new URIish("file:///" + repository1.getRepository().getDirectory().toString());
    CloneOperation clop = new CloneOperation(uri, true, null, workdir2, "refs/heads/master", "origin", 0);
    clop.run(null);/*from w w w .j  a  v a2 s. c  o m*/

    Repository clonedRepo = new FileRepository(new File(workdir2, Constants.DOT_GIT));
    assertEquals("", uri.toString(),
            clonedRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "url"));
    assertEquals("", "+refs/heads/*:refs/remotes/origin/*",
            clonedRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "fetch"));

    File file = new File(workdir2, "file1.txt");
    assertTrue(file.exists());
}

From source file:org.eclipse.egit.core.test.op.CloneOperationTest.java

License:Open Source License

@Test
public void testSimplePostCloneTask() throws Exception {
    URIish uri = new URIish("file:///" + repository1.getRepository().getDirectory().toString());
    CloneOperation clop = new CloneOperation(uri, true, null, workdir2, "refs/heads/master", "origin", 0);

    final File[] repoDir = new File[1];
    clop.addPostCloneTask(new PostCloneTask() {

        public void execute(Repository repository, IProgressMonitor monitor) throws CoreException {
            repoDir[0] = repository.getDirectory();

        }//w  ww . ja  v  a  2s . c o m
    });
    clop.run(null);
    File newRepoDir = new File(workdir2, Constants.DOT_GIT);
    assertEquals(newRepoDir, repoDir[0]);
}

From source file:org.eclipse.egit.core.test.op.CloneOperationTest.java

License:Open Source License

@Test
public void testConfigurePushAfterCloneTask() throws Exception {
    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 ConfigurePushAfterCloneTask("origin", "HEAD:refs/for/master",
            new URIish("file:///pushtarget")));
    clop.run(null);//from   ww  w .j a va2s  .  c om
    Repository clonedRepo = new FileRepository(new File(workdir2, Constants.DOT_GIT));
    assertEquals("", "HEAD:refs/for/master",
            clonedRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "push"));
    assertEquals("", "file:///pushtarget",
            clonedRepo.getConfig().getString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", "pushurl"));
}

From source file:org.eclipse.egit.core.test.op.CloneOperationTest.java

License:Open Source License

@Test
public void testConfigureFetchAfterCloneTask() throws Exception {
    createNoteInOrigin();/*w  ww .  j  ava  2 s. c  o  m*/

    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 = new FileRepository(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());
}

From source file:org.eclipse.egit.core.test.op.CommitOperationTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    super.setUp();
    gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    repository = testRepository.getRepository();
    testRepository.connect(project.getProject());
}

From source file:org.eclipse.egit.core.test.op.ConnectProviderOperationTest.java

License:Open Source License

@Test
public void testNoRepository() throws CoreException {

    ConnectProviderOperation operation = new ConnectProviderOperation(project.getProject(),
            new File("../..", Constants.DOT_GIT));
    operation.execute(null);//from  w  w w  .  j a  v a  2 s.  com

    assertFalse(RepositoryProvider.isShared(project.getProject()));
    assertTrue(!gitDir.exists());
}