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

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

Introduction

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

Prototype

String MASTER

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

Click Source Link

Document

Default main branch name

Usage

From source file:org.eclipse.egit.ui.internal.clone.CloneDestinationPage.java

License:Open Source License

/**
 * @return initial branch selected (includes refs/heads prefix).
 */// ww w .j  ava  2 s. c  om
public String getInitialBranch() {
    final int ix = initialBranch.getSelectionIndex();
    if (ix < 0)
        return Constants.R_HEADS + Constants.MASTER;
    return Constants.R_HEADS + initialBranch.getItem(ix);
}

From source file:org.eclipse.egit.ui.internal.clone.GerritConfigurationPage.java

License:Open Source License

private void setDefaults(RepositorySelection selection) {
    URIish uri = selection.getURI();//  w ww  .j  a  va  2 s .  com
    URIish newPushURI = uri;
    if (Protocol.SSH.handles(uri)) {
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (Protocol.GIT.handles(uri)) {
        newPushURI = newPushURI.setScheme(Protocol.SSH.getDefaultScheme());
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (isHttpProtocol(uri)) {
        newPushURI = prependGerritHttpPathPrefix(newPushURI);
    }
    uriText.setText(newPushURI.toString());
    final String uriScheme = newPushURI.getScheme();
    if (uriScheme != null)
        scheme.select(scheme.indexOf(uriScheme));
    branch.setText(Constants.MASTER);
}

From source file:org.eclipse.egit.ui.internal.gerrit.GerritConfigurationPage.java

License:Open Source License

private void setDefaults(URIish uri, String targetBranch) {
    URIish newPushURI = uri;/* w w  w.  j  a  v a 2 s .c  om*/
    if (Protocol.SSH.handles(uri)) {
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (Protocol.GIT.handles(uri)) {
        newPushURI = newPushURI.setScheme(Protocol.SSH.getDefaultScheme());
        newPushURI = newPushURI.setPort(GERRIT_DEFAULT_SSH_PORT);
    } else if (isHttpProtocol(uri)) {
        newPushURI = prependGerritHttpPathPrefix(newPushURI);
    }
    uriText.setText(newPushURI.toString());
    final String uriScheme = newPushURI.getScheme();
    if (uriScheme != null)
        scheme.select(scheme.indexOf(uriScheme));
    branch.setText(targetBranch != null ? targetBranch : Constants.MASTER);
}

From source file:org.eclipse.egit.ui.submodule.SubmoduleUpdateTest.java

License:Open Source License

@Test
public void updateSubmodule() throws Exception {
    deleteAllProjects();/* w  w  w  .ja  va  2 s  . c om*/
    assertProjectExistence(PROJ1, false);
    clearView();
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(repositoryFile);
    shareProjects(repositoryFile);
    assertProjectExistence(PROJ1, true);
    refreshAndWait();
    assertHasRepo(repositoryFile);
    FileRepository repo = lookupRepository(repositoryFile);
    ObjectId repoHead = repo.resolve(Constants.HEAD);

    SubmoduleAddCommand command = new SubmoduleAddCommand(repo);
    String path = "sub";
    command.setPath(path);
    String uri = new URIish(repo.getDirectory().toURI().toString()).toString();
    command.setURI(uri);
    Repository subRepo = command.call();
    assertNotNull(subRepo);

    Ref head = subRepo.getRef(Constants.HEAD);
    assertNotNull(head);
    assertTrue(head.isSymbolic());
    assertEquals(Constants.R_HEADS + Constants.MASTER, head.getLeaf().getName());
    assertEquals(repoHead, head.getObjectId());

    refreshAndWait();
    SWTBotTree tree = getOrOpenView().bot().tree();
    tree.getAllItems()[0].expand().expandNode(UIText.RepositoriesViewLabelProvider_SubmodulesNodeText).select();
    ContextMenuHelper.clickContextMenuSync(tree,
            myUtil.getPluginLocalizedValue(UPDATE_SUBMODULE_CONTEXT_MENU_LABEL));
    TestUtil.joinJobs(JobFamilies.SUBMODULE_UPDATE);
    refreshAndWait();

    head = subRepo.getRef(Constants.HEAD);
    assertNotNull(head);
    assertFalse(head.isSymbolic());
    assertEquals(repoHead, head.getObjectId());
}

From source file:org.eclipse.egit.ui.test.history.HistoryViewTest.java

License:Open Source License

@Test
public void testCheckOut() throws Exception {
    Repository repo = lookupRepository(repoFile);
    assertEquals(Constants.MASTER, repo.getBranch());

    final SWTBotTable table = getHistoryViewTable(PROJ1);
    // check out the second line
    table.getTableItem(1).select();/*from w  w  w. j av a2s  .  co  m*/
    final RevCommit[] commit = new RevCommit[1];

    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            TableItem tableItem = table.widget.getSelection()[0];
            ensureTableItemLoaded(tableItem);
            commit[0] = (RevCommit) tableItem.getData();
        }
    });

    ContextMenuHelper.clickContextMenu(table, UIText.GitHistoryPage_CheckoutMenuLabel);
    TestUtil.joinJobs(JobFamilies.CHECKOUT);
    assertEquals(commit[0].getId().name(), repo.getBranch());
}

From source file:org.eclipse.egit.ui.wizards.clone.GitCloneWizardTest.java

License:Open Source License

@Test
public void clonedRepositoryShouldExistOnFileSystem() {
    importWizard.openWizard();//from  w w  w  .  ja  v a 2 s.c o  m
    RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
    RepoRemoteBranchesPage remoteBranches = repoProperties.nextToRemoteBranches(r.getUri());
    remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
    WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
    workingCopy.assertWorkingCopyExists();
}

From source file:org.eclipse.egit.ui.wizards.clone.GitCloneWizardTestBase.java

License:Open Source License

protected void cloneRepo(File destRepo, RepoRemoteBranchesPage remoteBranches) throws Exception {
    remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
    remoteBranches.selectBranches(SampleTestRepository.FIX, Constants.MASTER);

    WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
    workingCopy.setDirectory(destRepo.toString());

    workingCopy.assertDirectory(destRepo.toString());
    workingCopy.assertBranch(Constants.MASTER);
    workingCopy.assertRemoteName(Constants.DEFAULT_REMOTE_NAME);
    workingCopy.waitForCreate();/*from w  ww .  ja  v a 2 s .com*/

    // Some random sampling to see we got something. We do not test
    // the integrity of the repository here. Only a few basic properties
    // we'd expect from a clone made this way, that would possibly
    // not hold true given other parameters in the GUI.
    Repository repository = new FileRepository(new File(destRepo, Constants.DOT_GIT));
    // we always have an origin/master
    assertNotNull(repository.resolve("origin/master"));
    // and a local master initialized from origin/master (default!)
    assertEquals(repository.resolve("master"), repository.resolve("origin/master"));
    // A well known tag
    assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v1_0_name).name());
    // lots of refs
    int refs = repository.getAllRefs().size();
    assertTrue(refs >= 4);
    // and a known file in the working dir
    assertTrue(new File(destRepo, SampleTestRepository.A_txt_name).exists());
    DirCacheEntry fileEntry = null;
    DirCache dc = repository.lockDirCache();
    fileEntry = dc.getEntry(SampleTestRepository.A_txt_name);
    dc.unlock();
    // check that we have the file in the index
    assertNotNull(fileEntry);
    // No project has been imported
    assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
}

From source file:org.eclipse.egit.ui.wizards.clone.SampleTestRepository.java

License:Open Source License

private void generateSampleData(int n) throws Exception {
    A_txt = src.blob("A");
    A = src.commit().add(A_txt_name, A_txt).create();
    src.update(Constants.R_HEADS + Constants.MASTER, A);

    // create some random commits
    RevCommit X = A;/*ww  w.  ja  v  a  2 s.c o  m*/
    for (int i = 0; i < n; i++) {
        X = src.commit().parent(X).add(randomAsciiString(), randomAsciiString()).create();
    }

    B = src.commit().parent(X).add(A_txt_name, "C").add("B", "B").create();
    src.update(Constants.R_HEADS + Constants.MASTER, B);

    v1_0 = src.tag(v1_0_name, B);
    src.update(Constants.R_TAGS + v1_0_name, v1_0);

    C = src.commit().parent(A).add(A_txt_name, "D").add("C", "C").create();
    src.update(Constants.R_HEADS + FIX, C);

    v2_0 = src.tag(v2_0_name, C);
    src.update(Constants.R_TAGS + v2_0_name, v2_0);
}

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.internal.github.ui.RepositoryImportWizard.java

License:Open Source License

private CloneOperation createCloneOperation(SearchRepository repo, RepositoryService service)
        throws IOException, URISyntaxException {
    Repository fullRepo = service.getRepository(repo);
    URIish uri = new URIish(fullRepo.getCloneUrl());

    IPreferenceStore store = org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore();

    String defaultRepoDir = store.getString(UIPreferences.DEFAULT_REPO_DIR);
    File directory = new File(new File(defaultRepoDir, repo.getOwner()), repo.getName());

    int timeout = store.getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);

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