Example usage for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE

List of usage examples for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE.

Prototype

String CONFIG_KEY_REMOTE

To view the source code for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE.

Click Source Link

Document

The "remote" key

Usage

From source file:org.eclipse.egit.ui.internal.push.PushToUpstreamTest.java

License:Open Source License

@Test
public void pushWithExistingUpstreamConfiguration() throws Exception {
    checkoutNewLocalBranch("bar");
    // Existing configuration
    repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "bar",
            ConfigConstants.CONFIG_KEY_REMOTE, "fetch");
    repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "bar",
            ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/bar");

    pushToUpstream();/*from w w w  . ja  v  a2 s. co  m*/
    assertBranchPushed("bar", remoteRepository);
}

From source file:org.eclipse.egit.ui.internal.push.SimpleConfigurePushDialog.java

License:Open Source License

/**
 * Add a warning about this remote being used by other branches
 *
 * @param parent//from   w  w w .jav  a  2s.  com
 */
private void addDefaultOriginWarningIfNeeded(Composite parent) {
    if (!showBranchInfo)
        return;
    List<String> otherBranches = new ArrayList<String>();
    String currentBranch;
    try {
        currentBranch = repository.getBranch();
    } catch (IOException e) {
        // just don't show this warning
        return;
    }
    String currentRemote = config.getName();
    Config repositoryConfig = repository.getConfig();
    Set<String> branches = repositoryConfig.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);
    for (String branch : branches) {
        if (branch.equals(currentBranch))
            continue;
        String remote = repositoryConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
                ConfigConstants.CONFIG_KEY_REMOTE);
        if ((remote == null && currentRemote.equals(Constants.DEFAULT_REMOTE_NAME))
                || (remote != null && remote.equals(currentRemote)))
            otherBranches.add(branch);
    }
    if (otherBranches.isEmpty())
        return;

    Composite warningAboutOrigin = new Composite(parent, SWT.NONE);
    warningAboutOrigin.setLayout(new GridLayout(2, false));
    Label warningLabel = new Label(warningAboutOrigin, SWT.NONE);
    warningLabel
            .setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
    Text warningText = new Text(warningAboutOrigin, SWT.READ_ONLY);
    warningText.setText(NLS.bind(UIText.SimpleConfigurePushDialog_ReusedOriginWarning, config.getName(),
            Integer.valueOf(otherBranches.size())));
    warningText.setToolTipText(otherBranches.toString());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(warningLabel);
}

From source file:org.eclipse.egit.ui.internal.repository.BranchPropertySource.java

License:Open Source License

public IPropertyDescriptor[] getPropertyDescriptors() {
    List<IPropertyDescriptor> resultList = new ArrayList<IPropertyDescriptor>();

    PropertyDescriptor desc = new PropertyDescriptor(ConfigConstants.CONFIG_KEY_MERGE,
            UIText.BranchPropertySource_UpstreamBranchDescriptor);
    desc.setCategory(UIText.BranchPropertySource_UpstreamConfigurationCategory);
    resultList.add(desc);//  w  w w  .j av  a 2s  .co  m
    desc = new PropertyDescriptor(ConfigConstants.CONFIG_KEY_REMOTE,
            UIText.BranchPropertySource_RemoteDescriptor);
    desc.setCategory(UIText.BranchPropertySource_UpstreamConfigurationCategory);
    resultList.add(desc);
    desc = new PropertyDescriptor(ConfigConstants.CONFIG_KEY_REBASE,
            UIText.BranchPropertySource_RebaseDescriptor);
    desc.setCategory(UIText.BranchPropertySource_UpstreamConfigurationCategory);
    resultList.add(desc);

    return resultList.toArray(new IPropertyDescriptor[0]);
}

From source file:org.eclipse.egit.ui.view.synchronize.SynchronizeViewPushTest.java

License:Open Source License

@Before
public void prepare() throws Exception {
    FileRepository childRepository = lookupRepository(childRepositoryFile);

    FileRepository repository = lookupRepository(repositoryFile);
    FileBasedConfig config = repository.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
    remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL()));
    remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    remoteConfig.update(config);/*from ww  w . j  ava  2 s. co m*/

    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE,
            "origin");
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE,
            "refs/heads/master");
    config.save();

    FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false);
    fetchOperation.run(null);
}

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

License:Open Source License

/**
 * Configure pull request topic branch to use head remote
 *
 * @param repo/*  www  .  j  a  va 2  s .c o  m*/
 * @param request
 * @throws IOException
 */
public static void configureTopicBranch(Repository repo, PullRequest request) throws IOException {
    String branch = getBranchName(request);
    String remote = request.getHead().getRepo().getOwner().getLogin();
    StoredConfig config = repo.getConfig();
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_MERGE,
            getHeadBranch(request));
    config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE, remote);
    config.save();
}

From source file:org.eclipse.oomph.gitbash.decorators.BranchDecorator.java

License:Open Source License

private String getDecoration(org.eclipse.egit.ui.internal.repository.tree.RefNode node) {
    String branchName = Repository.shortenRefName(node.getObject().getName());
    Repository repository = node.getRepository();
    StoredConfig config = repository.getConfig();

    String branch = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
            ConfigConstants.CONFIG_KEY_MERGE);

    if (branch != null) {
        String remote = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
                ConfigConstants.CONFIG_KEY_REMOTE);

        boolean rebaseFlag = config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
                ConfigConstants.CONFIG_KEY_REBASE, false);

        if (branch.startsWith(DEFAULT_PATH)) {
            branch = branch.substring(DEFAULT_PATH.length());
        }//from  w w w.  java2  s .c  o m

        String prefix = ".".equals(remote) ? "" : remote + "/";
        String result = (rebaseFlag ? "REBASE" : "MERGE") + ": " + prefix + branch;

        try {
            BranchTrackingStatus trackingStatus = BranchTrackingStatus.of(repository, branchName);
            if (trackingStatus != null
                    && (trackingStatus.getAheadCount() != 0 || trackingStatus.getBehindCount() != 0)) {
                result += " " + formatBranchTrackingStatus(trackingStatus);
            }
        } catch (Throwable t) {
            //$FALL-THROUGH$
        }

        return result;
    }

    return null;
}

From source file:org.eclipse.orion.server.git.BaseToRemoteConverter.java

License:Open Source License

public static URI getRemoteBranchLocation(URI base, String branchName, Repository db,
        BaseToRemoteConverter converter) throws IOException, URISyntaxException {
    Config repoConfig = db.getConfig();/*from  www.j ava2 s.co  m*/
    String remote = repoConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
            ConfigConstants.CONFIG_KEY_REMOTE);
    if (remote == null)
        // fall back to default remote
        remote = Constants.DEFAULT_REMOTE_NAME;
    String fetch = repoConfig.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, "fetch"); //$NON-NLS-1$
    if (fetch != null) {
        // expecting something like: +refs/heads/*:refs/remotes/origin/*
        String[] split = fetch.split(":"); //$NON-NLS-1$
        if (split[0].endsWith("*") /*src*/ && split[1].endsWith("*") /*dst*/) { //$NON-NLS-1$ //$NON-NLS-2$
            return converter.baseToRemoteLocation(base, remote, branchName);
        }
    }
    return null;
}

From source file:org.eclipse.orion.server.git.objects.Branch.java

License:Open Source License

@PropertyDescription(name = GitConstants.KEY_REMOTE)
private JSONArray getRemotes() throws URISyntaxException, JSONException, IOException, CoreException {
    String branchName = Repository.shortenRefName(ref.getName());
    JSONArray result = new JSONArray();
    String remoteName = getConfig().getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
            ConfigConstants.CONFIG_KEY_REMOTE);
    if (remoteName != null) {
        RemoteConfig remoteConfig = new RemoteConfig(getConfig(), remoteName);
        if (!remoteConfig.getFetchRefSpecs().isEmpty()) {
            Remote remote = new Remote(cloneLocation, db, remoteName);
            remote.setNewBranch(branchName);
            result.put(remote.toJSON());
        }//w  ww .j  a va2s . c om
    } else {
        List<RemoteConfig> remoteConfigs = RemoteConfig.getAllRemoteConfigs(getConfig());
        for (RemoteConfig remoteConfig : remoteConfigs) {
            if (!remoteConfig.getFetchRefSpecs().isEmpty()) {
                Remote r = new Remote(cloneLocation, db, remoteConfig.getName());
                r.setNewBranch(branchName);
                if (db.resolve(Constants.R_REMOTES + remoteConfig.getName() + "/" + branchName) != null) { //$NON-NLS-1$
                    // it's an existing branch, not a new one, use it as filter
                    return new JSONArray().put(r.toJSON());
                }
                result.put(r.toJSON());
            }
        }
    }
    return result;
}

From source file:org.flowerplatform.web.git.explorer.Remote_VirtualItemChildrenProvider.java

License:Open Source License

@Override
public Collection<Pair<Object, String>> getChildrenForNode(Object node, TreeNode treeNode,
        GenericTreeContext context) {/*from  w  w w . j  a v  a  2  s. com*/
    @SuppressWarnings("unchecked")
    Repository repository = ((Pair<Repository, String>) node).a;
    Collection<Pair<Object, String>> result = new ArrayList<Pair<Object, String>>();

    Set<String> configNames = repository.getConfig().getSubsections(ConfigConstants.CONFIG_KEY_REMOTE);

    Pair<Object, String> child;
    RemoteNode realChild;
    for (String configName : configNames) {
        realChild = new RemoteNode(repository, configName);
        child = new Pair<Object, String>(realChild, GitNodeType.NODE_TYPE_REMOTE);
        result.add(child);
    }
    return result;
}

From source file:org.flowerplatform.web.git.explorer.Remote_VirtualItemChildrenProvider.java

License:Open Source License

@Override
public Boolean nodeHasChildren(Object node, TreeNode treeNode, GenericTreeContext context) {
    @SuppressWarnings("unchecked")
    Repository repository = ((Pair<Repository, String>) node).a;
    return repository.getConfig().getSubsections(ConfigConstants.CONFIG_KEY_REMOTE).size() > 0;
}