List of usage examples for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_MERGE
String CONFIG_KEY_MERGE
To view the source code for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_MERGE.
Click Source Link
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizardTest.java
License:Open Source License
@Test public void pushWithLocalUpstreamConfiguration() throws Exception { checkoutNewLocalBranch("foo"); // Existing configuration repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "foo", ConfigConstants.CONFIG_KEY_REMOTE, "."); repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "foo", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/master"); PushBranchWizardTester wizard = PushBranchWizardTester.startWizard(selectProject(), "foo"); wizard.selectRemote("fetch"); wizard.assertBranchName("foo"); wizard.assertMergeSelected();//from w ww. ja va 2 s . co m assertTrue(wizard.isUpstreamConfigOverwriteWarningShown()); wizard.deselectConfigureUpstream(); assertFalse(wizard.isUpstreamConfigOverwriteWarningShown()); wizard.selectMerge(); wizard.next(); wizard.finish(); ObjectId remoteId = remoteRepository.resolve("foo"); ObjectId localId = repository.resolve("foo"); assertEquals(localId, remoteId); // Newly configured assertBranchConfig("foo", "fetch", "refs/heads/foo", "false"); }
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizardTest.java
License:Open Source License
private void assertBranchConfig(String branchName, String remoteName, String mergeRef, String rebase) { StoredConfig config = repository.getConfig(); assertEquals(remoteName, config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE)); assertEquals(mergeRef, config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE)); assertEquals(rebase, config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE)); }
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();// w w w . j ava 2 s .com assertBranchPushed("bar", remoteRepository); }
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);/*from ww w . j av a 2 s. com*/ 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 w w w .j av a2 s . com*/ 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/*from w ww .ja va2 s.c om*/ * @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. ja va 2s . co 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.fedoraproject.eclipse.packager.git.FpGitProjectBits.java
License:Open Source License
/** * Determine if there are unpushed changes on the current branch. * @return If there are unpushed changes. *///from w ww.ja va2s . c om @Override public boolean hasLocalChanges(IProjectRoot fedoraProjectRoot) { if (!isInitialized()) { // FIXME: raise exception instead. return true; // If we are not initialized we can't go any further! } try { // get remote ref from config String branchName = git.getRepository().getBranch(); String trackingRemoteBranch = git.getRepository().getConfig() .getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE); /////////////////////////////////////////////////////////// // FIXME: Temp work-around for Eclipse EGit/JGit BZ #317411 FetchCommand fetch = git.fetch(); fetch.setRemote("origin"); //$NON-NLS-1$ fetch.setTimeout(0); // Fetch refs for current branch; account for f14 + f14/master like // branch names. Need to fetch into remotes/origin/f14/master since // this is what is later used for local changes comparison. String fetchBranchSpec = Constants.R_HEADS + branchName + ":" + //$NON-NLS-1$ Constants.R_REMOTES + "origin/" + branchName; //$NON-NLS-1$ if (trackingRemoteBranch != null) { // have f14/master like branch trackingRemoteBranch = trackingRemoteBranch.substring(Constants.R_HEADS.length()); fetchBranchSpec = Constants.R_HEADS + trackingRemoteBranch + ":" + //$NON-NLS-1$ Constants.R_REMOTES + "origin/" + trackingRemoteBranch; //$NON-NLS-1$ } RefSpec spec = new RefSpec(fetchBranchSpec); fetch.setRefSpecs(spec); try { fetch.call(); } catch (JGitInternalException e) { e.printStackTrace(); } catch (InvalidRemoteException e) { e.printStackTrace(); } //--- End temp work-around for EGit/JGit bug. RevWalk rw = new RevWalk(git.getRepository()); ObjectId objHead = git.getRepository().resolve(branchName); if (trackingRemoteBranch == null) { // no config yet, assume plain brach name. trackingRemoteBranch = branchName; } RevCommit commitHead = rw.parseCommit(objHead); ObjectId objRemoteTrackingHead = git.getRepository().resolve("origin/" + //$NON-NLS-1$ trackingRemoteBranch); RevCommit remoteCommitHead = rw.parseCommit(objRemoteTrackingHead); return !commitHead.equals(remoteCommitHead); } catch (NoWorkTreeException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return true; }
From source file:org.flowerplatform.web.git.GitService.java
License:Open Source License
@RemoteInvocation public ConfigBranchPageDto getConfigBranchData(ServiceInvocationContext context, List<PathFragment> path) { try {/* w ww. ja va2 s . co m*/ RefNode node = (RefNode) GenericTreeStatefulService.getNodeByPathFor(path, null); Repository repository = node.getRepository(); StoredConfig config = repository.getConfig(); ConfigBranchPageDto dto = new ConfigBranchPageDto(); Ref branch = (Ref) node.getRef(); dto.setRef(new GitRef(branch.getName(), Repository.shortenRefName(branch.getName()))); List<RemoteConfig> remotes = getAllRemotes(context, path); String branchName = branch.getName().substring(Constants.R_HEADS.length()); String branchConfig = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE); String remoteConfig = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE); if (remoteConfig == null) { remoteConfig = ""; } if (remotes != null) { dto.setRemotes(remotes); for (RemoteConfig remote : remotes) { if (remote.getName().equals(remoteConfig)) { List<Object> branches = getBranches(context, remote.getUri()); if (branches != null) { @SuppressWarnings("unchecked") List<GitRef> refs = (List<GitRef>) branches.get(0); for (GitRef ref : refs) { if (ref.getName().equals(branchConfig)) { dto.setSelectedRef(ref); break; } } dto.setRefs(refs); } dto.setSelectedRemote(remote); break; } } } boolean rebaseFlag = config.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE, false); dto.setRebase(rebaseFlag); return dto; } catch (Exception e) { logger.debug(CommonPlugin.getInstance().getMessage("error"), path, e); context.getCommunicationChannel().appendOrSendCommand( new DisplaySimpleMessageClientCommand(CommonPlugin.getInstance().getMessage("error"), e.getMessage(), DisplaySimpleMessageClientCommand.ICON_ERROR)); return null; } }
From source file:org.flowerplatform.web.git.GitService.java
License:Open Source License
@RemoteInvocation public boolean configBranch(ServiceInvocationContext context, List<PathFragment> path, GitRef upstreamBranch, RemoteConfig remote, boolean rebase) { try {//from www. j ava 2 s . com RefNode node = (RefNode) GenericTreeStatefulService.getNodeByPathFor(path, null); Repository repository = node.getRepository(); StoredConfig config = repository.getConfig(); Ref ref; if (node instanceof Ref) { ref = node.getRef(); } else { // get remote branch String dst = Constants.R_REMOTES + remote.getName(); String remoteRefName = dst + "/" + upstreamBranch.getShortName(); ref = repository.getRef(remoteRefName); if (ref == null) { // doesn't exist, fetch it RefSpec refSpec = new RefSpec(); refSpec = refSpec.setForceUpdate(true); refSpec = refSpec.setSourceDestination(upstreamBranch.getName(), remoteRefName); new Git(repository).fetch().setRemote(new URIish(remote.getUri()).toPrivateString()) .setRefSpecs(refSpec).call(); ref = repository.getRef(remoteRefName); } } String branchName = node.getRef().getName().substring(Constants.R_HEADS.length()); if (upstreamBranch.getName().length() > 0) { config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE, upstreamBranch.getName()); } else { config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE); } if (remote.getName().length() > 0) { config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE, remote.getName()); } else { config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE); } if (rebase) { config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE, true); } else { config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REBASE); } config.save(); return true; } catch (Exception e) { logger.debug(CommonPlugin.getInstance().getMessage("error"), path, e); context.getCommunicationChannel().appendOrSendCommand( new DisplaySimpleMessageClientCommand(CommonPlugin.getInstance().getMessage("error"), e.getMessage(), DisplaySimpleMessageClientCommand.ICON_ERROR)); return false; } }