Search in sources :

Example 1 with PushOperationUI

use of org.eclipse.egit.ui.internal.push.PushOperationUI in project egit by eclipse.

the class GitRepositoriesViewFetchAndPushTest method testFetchFromOrigin.

private void testFetchFromOrigin(boolean useRemote) throws Exception {
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile);
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(clonedRepositoryFile2);
    Repository repository = lookupRepository(clonedRepositoryFile2);
    // add the configuration for push from cloned2
    repository.getConfig().setString("remote", "origin", "push", "refs/heads/*:refs/heads/*");
    repository.getConfig().save();
    SWTBotTree tree = getOrOpenView().bot().tree();
    String destinationString = clonedRepositoryFile.getParentFile().getName() + " - " + "origin";
    String dialogTitle = NLS.bind(UIText.FetchResultDialog_title, destinationString);
    selectNode(tree, useRemote, true);
    runFetch(tree);
    bot.waitUntil(Conditions.shellIsActive(dialogTitle));
    SWTBotShell confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
    confirm.close();
    deleteAllProjects();
    shareProjects(clonedRepositoryFile2);
    String objid = repository.exactRef("refs/heads/master").getTarget().getObjectId().name();
    objid = objid.substring(0, 7);
    touchAndSubmit(null);
    // push from other repository
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.PUSH, 60, TimeUnit.SECONDS);
    PushOperationUI op = new PushOperationUI(repository, "origin", false);
    op.start();
    TestUtil.openJobResultDialog(jobJoiner.join());
    String pushdialogTitle = NLS.bind(UIText.PushResultDialog_title, op.getDestinationString());
    bot.shell(pushdialogTitle).close();
    deleteAllProjects();
    refreshAndWait();
    selectNode(tree, useRemote, true);
    runFetch(tree);
    bot.waitUntil(Conditions.shellIsActive(dialogTitle));
    confirm = bot.shell(dialogTitle);
    SWTBotTreeItem[] treeItems = confirm.bot().tree().getAllItems();
    boolean found = false;
    for (SWTBotTreeItem item : treeItems) {
        found = item.getText().contains(objid);
        if (found)
            break;
    }
    assertTrue(found);
    confirm.close();
    selectNode(tree, useRemote, true);
    runFetch(tree);
    confirm = bot.shell(dialogTitle);
    assertEquals("Wrong result tree row count", 0, confirm.bot().tree().rowCount());
}
Also used : Repository(org.eclipse.jgit.lib.Repository) JobJoiner(org.eclipse.egit.ui.test.JobJoiner) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Example 2 with PushOperationUI

use of org.eclipse.egit.ui.internal.push.PushOperationUI in project egit by eclipse.

the class PushConfiguredRemoteCommand method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    RepositoryTreeNode node = getSelectedNodes(event).get(0);
    RemoteConfig config = getRemoteConfig(node);
    if (config == null) {
        MessageDialog.openInformation(getShell(event), UIText.SimplePushActionHandler_NothingToPushDialogTitle, UIText.SimplePushActionHandler_NothingToPushDialogMessage);
        return null;
    }
    new PushOperationUI(node.getRepository(), config.getName(), false).start();
    return null;
}
Also used : RepositoryTreeNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 3 with PushOperationUI

use of org.eclipse.egit.ui.internal.push.PushOperationUI in project egit by eclipse.

the class SimplePushActionHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Repository repository = getRepository(true, event);
    if (repository == null)
        return null;
    RemoteConfig config = SimpleConfigurePushDialog.getConfiguredRemote(repository);
    if (config == null) {
        MessageDialog.openInformation(getShell(event), UIText.SimplePushActionHandler_NothingToPushDialogTitle, UIText.SimplePushActionHandler_NothingToPushDialogMessage);
        return null;
    }
    PushOperationUI op = new PushOperationUI(repository, config.getName(), false);
    op.start();
    return null;
}
Also used : Repository(org.eclipse.jgit.lib.Repository) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) RemoteConfig(org.eclipse.jgit.transport.RemoteConfig)

Example 4 with PushOperationUI

use of org.eclipse.egit.ui.internal.push.PushOperationUI in project egit by eclipse.

the class PushUpstreamOrBranchActionHandler method pushOrConfigure.

/**
 * @param repository
 * @param config
 * @param shell
 */
public static void pushOrConfigure(final Repository repository, RemoteConfig config, Shell shell) {
    if (config != null) {
        PushOperationUI op = new PushOperationUI(repository, config.getName(), false);
        op.start();
    } else {
        Ref head = getHeadIfSymbolic(repository);
        if (head != null) {
            PushBranchWizard pushBranchWizard = new PushBranchWizard(repository, head);
            PushWizardDialog dlg = new PushWizardDialog(shell, pushBranchWizard);
            dlg.open();
        }
    }
}
Also used : Ref(org.eclipse.jgit.lib.Ref) PushWizardDialog(org.eclipse.egit.ui.internal.push.PushWizardDialog) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) PushBranchWizard(org.eclipse.egit.ui.internal.push.PushBranchWizard)

Example 5 with PushOperationUI

use of org.eclipse.egit.ui.internal.push.PushOperationUI in project egit by eclipse.

the class LocalRepositoryTestCase method createRemoteRepository.

protected File createRemoteRepository(File repositoryDir) throws Exception {
    Repository myRepository = lookupRepository(repositoryDir);
    File gitDir = new File(testDirectory, REPO2);
    Repository myRemoteRepository = FileRepositoryBuilder.create(gitDir);
    myRemoteRepository.create(true);
    // double-check that this is bare
    assertTrue(myRemoteRepository.isBare());
    createStableBranch(myRepository);
    // now we configure a pure push destination
    myRepository.getConfig().setString("remote", "push", "pushurl", "file:///" + myRemoteRepository.getDirectory().getPath());
    myRepository.getConfig().setString("remote", "push", "push", "+refs/heads/*:refs/heads/*");
    // and a pure fetch destination
    myRepository.getConfig().setString("remote", "fetch", "url", "file:///" + myRemoteRepository.getDirectory().getPath());
    myRepository.getConfig().setString("remote", "fetch", "fetch", "+refs/heads/*:refs/heads/*");
    // a destination with both fetch and push urls and specs
    myRepository.getConfig().setString("remote", "both", "pushurl", "file:///" + myRemoteRepository.getDirectory().getPath());
    myRepository.getConfig().setString("remote", "both", "push", "+refs/heads/*:refs/heads/*");
    myRepository.getConfig().setString("remote", "both", "url", "file:///" + myRemoteRepository.getDirectory().getPath());
    myRepository.getConfig().setString("remote", "both", "fetch", "+refs/heads/*:refs/heads/*");
    // a destination with only a fetch url and push and fetch specs
    myRepository.getConfig().setString("remote", "mixed", "push", "+refs/heads/*:refs/heads/*");
    myRepository.getConfig().setString("remote", "mixed", "url", "file:///" + myRemoteRepository.getDirectory().getPath());
    myRepository.getConfig().setString("remote", "mixed", "fetch", "+refs/heads/*:refs/heads/*");
    myRepository.getConfig().save();
    // and push
    PushOperationUI pa = new PushOperationUI(myRepository, "push", false);
    pa.execute(null);
    try {
        // delete the stable branch again
        RefUpdate op = myRepository.updateRef("refs/heads/stable");
        // $NON-NLS-1$
        op.setRefLogMessage(// $NON-NLS-1$
        "branch deleted", false);
        // we set the force update in order
        // to avoid having this rejected
        // due to minor issues
        op.setForceUpdate(true);
        op.delete();
    } catch (IOException ioe) {
        throw new InvocationTargetException(ioe);
    }
    return myRemoteRepository.getDirectory();
}
Also used : Repository(org.eclipse.jgit.lib.Repository) PushOperationUI(org.eclipse.egit.ui.internal.push.PushOperationUI) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) RefUpdate(org.eclipse.jgit.lib.RefUpdate)

Aggregations

PushOperationUI (org.eclipse.egit.ui.internal.push.PushOperationUI)7 Repository (org.eclipse.jgit.lib.Repository)4 RemoteConfig (org.eclipse.jgit.transport.RemoteConfig)4 PushBranchWizard (org.eclipse.egit.ui.internal.push.PushBranchWizard)2 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 IFile (org.eclipse.core.resources.IFile)1 GitSynchronizeData (org.eclipse.egit.core.synchronize.dto.GitSynchronizeData)1 GitSynchronizeDataSet (org.eclipse.egit.core.synchronize.dto.GitSynchronizeDataSet)1 EGitCredentialsProvider (org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider)1 PushToGerritWizard (org.eclipse.egit.ui.internal.push.PushToGerritWizard)1 PushWizardDialog (org.eclipse.egit.ui.internal.push.PushWizardDialog)1 RepositoryTreeNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode)1 JobJoiner (org.eclipse.egit.ui.test.JobJoiner)1 Wizard (org.eclipse.jface.wizard.Wizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Ref (org.eclipse.jgit.lib.Ref)1 RefUpdate (org.eclipse.jgit.lib.RefUpdate)1