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.ui.wizards.clone.SampleTestRepository.java

License:Open Source License

private void serve() throws IOException {
    d = new Daemon();
    d.exportRepository(REPO_NAME, src.getRepository());
    d.start();//from w  w w .j av a  2 s  . c o m
    uri = "git://localhost:" + d.getAddress().getPort() + "/" + REPO_NAME + Constants.DOT_GIT;
}

From source file:org.eclipse.egit.ui.wizards.share.SharingWizardTest.java

License:Open Source License

@Test
public void shareProjectWithNewlyCreatedRepo() throws Exception {
    ExistingOrNewPage existingOrNewPage = sharingWizard.openWizard(projectName);

    // initial state
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    String projectPath = workspace.getRoot().getProject(projectName).getLocation().toOSString();

    existingOrNewPage.assertContents(projectName, projectPath, "", "");
    existingOrNewPage.assertEnabling(false, false, false);

    // select project
    bot.tree().getTreeItem(projectName).select();
    existingOrNewPage.assertContents(projectName, projectPath, "", projectPath);
    existingOrNewPage.assertEnabling(true, true, false);

    // create repository
    bot.button("Create Repository").click();

    String repopath = workspace.getRoot().getProject(projectName).getLocation().append(Constants.DOT_GIT)
            .toOSString();//from   ww  w .ja  v a  2  s.c o  m
    existingOrNewPage.assertContents(projectName, projectPath, repopath, "");
    existingOrNewPage.assertEnabling(false, false, true);

    assertTrue((new File(repopath)).exists());

    // share project
    bot.button("Finish").click();
    Thread.sleep(1000);
    assertEquals("org.eclipse.egit.core.GitProvider", workspace.getRoot().getProject(projectName)
            .getPersistentProperty(new QualifiedName("org.eclipse.team.core", "repository")));
}

From source file:org.eclipse.emf.compare.diagram.papyrus.tests.egit.AbstractGitMergeTestCase.java

License:Open Source License

@Before
public void setUp() throws Exception {
    Activator.getDefault().getRepositoryCache().clear();
    final MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    final String gitRepoPath = workspaceRoot.getRawLocation().toFile() + File.separator + "repo";
    mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,
            workspaceRoot.getLocation().toFile().getParentFile().getAbsoluteFile().toString());
    gitDir = new File(gitRepoPath, Constants.DOT_GIT);
    repository = new GitTestRepository(gitDir);
    repository.ignore(workspaceRoot.getRawLocation().append(".metadata").toFile());
    setUpRepository();/*from  ww w .  ja  v  a 2  s . c om*/
}

From source file:org.eclipse.emf.compare.git.pgm.AbstractApplicationTest.java

License:Open Source License

@Before
public void before() throws Exception {
    // Creates a local git repository for test purpose
    testTmpFolder = Files.createTempDirectory(TMP_DIRECTORY_PREFIX, new FileAttribute<?>[] {});
    outputStream = new ByteArrayOutputStream();
    errStream = new ByteArrayOutputStream();
    sysout = System.out;//ww w  .j a v  a2 s.  c o  m
    syserr = System.err;

    // Redirects out and err in order to test outputs.
    System.setOut(new PrintStream(outputStream));
    System.setErr(new PrintStream(errStream));

    app = buildApp();
    setContext(new MockedApplicationContext());

    setRepositoryPath(Files.createTempDirectory(testTmpFolder, REPO_PREFIX, new FileAttribute<?>[] {}));
    setGitFolderPath(new File(getRepositoryPath().toFile(), Constants.DOT_GIT));
    git = Git.init().setDirectory(getRepositoryPath().toFile()).call();
    // Saves the user.dire property to be able to restore it.( some tests can modify it)
    userDir = System.getProperty("user.dir"); //$NON-NLS-1$

}

From source file:org.eclipse.emf.compare.ide.ui.tests.egit.CompareGitTestCase.java

License:Open Source License

@Override
@Before// w w  w  .  j a v a2  s.c om
public void setUp() throws Exception {
    super.setUp();
    // ensure there are no shared Repository instances left
    // when starting a new test
    Activator.getDefault().getRepositoryCache().clear();
    final MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY, ResourcesPlugin.getWorkspace().getRoot()
            .getLocation().toFile().getParentFile().getAbsoluteFile().toString());
    final IWorkspaceRoot workspaceRoot = project.getProject().getWorkspace().getRoot();
    gitDir = new File(workspaceRoot.getRawLocation().toFile(), Constants.DOT_GIT);
    repository = new GitTestRepository(gitDir);
    repository.connect(project.getProject());
    repository.ignore(workspaceRoot.getRawLocation().append(".metadata").toFile());
}

From source file:org.eclipse.emf.compare.ide.ui.tests.merge.RemoteNewProjectTests.java

License:Open Source License

@Override
@Before/*from  ww w  .  jav a2s  .c  o  m*/
public void setUp() throws Exception {
    // ensure there are no shared Repository instances left
    // when starting a new test
    Activator.getDefault().getRepositoryCache().clear();
    final MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
    String gitRepoPath = workspaceRoot.getRawLocation().toFile() + File.separator + "repo";
    mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,
            workspaceRoot.getLocation().toFile().getParentFile().getAbsoluteFile().toString());
    gitDir = new File(gitRepoPath, Constants.DOT_GIT);
    repository = new GitTestRepository(gitDir);
    repository.ignore(workspaceRoot.getRawLocation().append(".metadata").toFile());
}

From source file:org.eclipse.mylyn.internal.github.core.pr.PullRequestUtils.java

License:Open Source License

/**
 * Get Git repository for pull request//from  w ww .  jav a  2s. c om
 *
 * @param request
 * @return repository or null if none found
 */
public static Repository getRepository(PullRequest request) {
    org.eclipse.egit.github.core.Repository remoteRepo = request.getBase().getRepo();
    String id = remoteRepo.getOwner().getLogin() + '/' + remoteRepo.getName() + Constants.DOT_GIT;
    RepositoryCache cache = Activator.getDefault().getRepositoryCache();
    for (String path : Activator.getDefault().getRepositoryUtil().getConfiguredRepositories())
        try {
            Repository repo = cache.lookupRepository(new File(path));
            RemoteConfig rc = new RemoteConfig(repo.getConfig(), Constants.DEFAULT_REMOTE_NAME);
            for (URIish uri : rc.getURIs())
                if (uri.toString().endsWith(id))
                    return repo;
        } catch (IOException e) {
            GitHub.logError(e);
            continue;
        } catch (URISyntaxException e) {
            GitHub.logError(e);
            continue;
        }
    return null;
}

From source file:org.eclipse.mylyn.internal.github.ui.gist.CloneGistHandler.java

License:Open Source License

private CloneOperation createCloneOperation(TaskData data, String name) throws IOException, URISyntaxException {
    String pullUrl = data.getRoot().getAttribute(GistAttribute.CLONE_URL.getMetadata().getId()).getValue();
    URIish uri = new URIish(pullUrl);
    int timeout = Activator.getDefault().getPreferenceStore().getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
    final File workDir = new File(getParentDirectory(), name);

    if (getRepoUtil().getConfiguredRepositories()
            .contains(new File(workDir, Constants.DOT_GIT).getAbsolutePath()))
        throw new IOException(MessageFormat.format(Messages.CloneGistHandler_ErrorRepoExists, name));

    return new CloneOperation(uri, true, null, workDir, Constants.R_HEADS + Constants.MASTER,
            Constants.DEFAULT_REMOTE_NAME, timeout);
}

From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestUtils.java

License:Open Source License

private static Repository createRepository(IProject aProject) throws CoreException, IOException {
    TestUtils.waitForJobs();//from  w w  w .ja  va 2 s. c o  m
    File gitDir = new File(aProject.getLocation().toOSString(), Constants.DOT_GIT);
    Repository repository = new FileRepository(gitDir);
    try {
        repository.create();
        Config storedConfig = repository.getConfig();
        storedConfig.setEnum("core", null, "autocrlf", AutoCRLF.FALSE);

    } catch (IllegalStateException e) {
        //Jusy go on
    }
    return repository;
}

From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java

License:Open Source License

public Repository getLocalRepo() throws IOException {
    if (localRepo == null) {
        IPath p = new Path(getWorkingDir().getAbsolutePath()).append(Constants.DOT_GIT);
        // <absolute path to working dir>/.git
        localRepo = new FileRepository(p.toFile());
    }//from w  w  w  . j  ava 2  s . c o m
    return localRepo;
}