List of usage examples for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE
String CONFIG_KEY_REMOTE
To view the source code for org.eclipse.jgit.lib ConfigConstants CONFIG_KEY_REMOTE.
Click Source Link
From source file:org.eclipse.egit.core.test.GitProjectSetCapabilityTest.java
License:Open Source License
private File createRepository(IPath location, String url, String branch) throws Exception { File gitDirectory = new File(location.toFile(), Constants.DOT_GIT); Repository repo = new FileRepository(gitDirectory); repo.getConfig().setString(ConfigConstants.CONFIG_REMOTE_SECTION, "origin", ConfigConstants.CONFIG_KEY_URL, url);/*from w w w. ja v a 2 s . c o m*/ repo.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE, "origin"); repo.create(); repo.close(); Git git = new Git(repo); git.add().addFilepattern(".").call(); git.commit().setMessage("initial").call(); if (!branch.equals("master")) git.checkout().setName(branch).setCreateBranch(true).call(); pathsToClean.add(gitDirectory); return gitDirectory; }
From source file:org.eclipse.egit.ui.internal.dialogs.AbstractConfigureRemoteDialog.java
License:Open Source License
/** * Add a warning about this remote being used by other branches * * @param parent/*from w w w . jav a 2 s. co m*/ */ private void addDefaultOriginWarning(Composite parent) { List<String> otherBranches = new ArrayList<>(); String currentBranch; try { currentBranch = getRepository().getBranch(); } catch (IOException e) { // just don't show this warning return; } String currentRemote = getConfig().getName(); Config repositoryConfig = getRepository().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); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(warningAboutOrigin); 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.AbstractConfigureRemoteDialog_ReusedRemoteWarning, getConfig().getName(), Integer.valueOf(otherBranches.size()))); warningText.setToolTipText(otherBranches.toString()); GridDataFactory.fillDefaults().grab(true, false).applyTo(warningLabel); }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchConfigurationDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite main = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(main); GridDataFactory.fillDefaults().grab(true, false).indent(5, 5).applyTo(main); Label branchLabel = new Label(main, SWT.NONE); branchLabel.setText(UIText.BranchConfigurationDialog_UpstreamBranchLabel); branchText = new Combo(main, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(branchText); try {//from ww w . ja va 2s. c o m for (Ref ref : myRepository.getRefDatabase().getRefs(Constants.R_HEADS).values()) branchText.add(ref.getName()); for (Ref ref : myRepository.getRefDatabase().getRefs(Constants.R_REMOTES).values()) branchText.add(ref.getName()); } catch (IOException e) { Activator.logError(UIText.BranchConfigurationDialog_ExceptionGettingRefs, e); } Label remoteLabel = new Label(main, SWT.NONE); remoteLabel.setText(UIText.BranchConfigurationDialog_RemoteLabel); remoteText = new Combo(main, SWT.BORDER); GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteText); // TODO do we have a constant somewhere? remoteText.add("."); //$NON-NLS-1$ for (String remote : myConfig.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION)) remoteText.add(remote); rebase = new Button(main, SWT.CHECK); GridDataFactory.fillDefaults().span(2, 1).applyTo(rebase); rebase.setText(UIText.BranchConfigurationDialog_RebaseLabel); String branch = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE); if (branch == null) branch = ""; //$NON-NLS-1$ branchText.setText(branch); String remote = myConfig.getString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE); if (remote == null) remote = ""; //$NON-NLS-1$ remoteText.setText(remote); boolean rebaseFlag = myConfig.getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REBASE, false); rebase.setSelection(rebaseFlag); applyDialogFont(main); // return result; return main; }
From source file:org.eclipse.egit.ui.internal.dialogs.BranchConfigurationDialog.java
License:Open Source License
@Override protected void okPressed() { try {/*from www . ja va2 s.c o m*/ String merge = branchText.getText(); if (merge.length() > 0) myConfig.setString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE, merge); else myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_MERGE); String remote = remoteText.getText(); if (remote.length() > 0) myConfig.setString(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE, remote); else myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REMOTE); boolean rebaseFlag = rebase.getSelection(); if (rebaseFlag) myConfig.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REBASE, true); else myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION, myBranchName, ConfigConstants.CONFIG_KEY_REBASE); try { myConfig.save(); super.okPressed(); } catch (IOException e) { Activator.handleError(UIText.BranchConfigurationDialog_SaveBranchConfigFailed, e, true); } } catch (RuntimeException e) { Activator.handleError(e.getMessage(), e, true); } }
From source file:org.eclipse.egit.ui.internal.fetch.SimpleConfigureFetchDialog.java
License:Open Source License
/** * Add a warning about this remote being used by other branches * * @param parent//from ww w.j a v 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.SimpleConfigureFetchDialog_ReusedRemoteWarning, 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.pull.PullWizard.java
License:Open Source License
private void configureUpstream() throws IOException { String fullBranch = this.repository.getFullBranch(); if (fullBranch == null || !fullBranch.startsWith(Constants.R_HEADS)) { // Don't configure upstream for detached HEAD return;/*from w w w . ja va2s.c om*/ } String remoteName = this.page.getRemoteConfig().getName(); String fullRemoteBranchName = this.page.getFullRemoteReference(); String localBranchName = this.repository.getBranch(); StoredConfig config = repository.getConfig(); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REMOTE, remoteName); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_MERGE, fullRemoteBranchName); BranchRebaseMode rebaseMode = this.page.getUpstreamConfig(); if (rebaseMode != null) { config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REBASE, rebaseMode); } config.save(); }
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizard.java
License:Open Source License
private void configureUpstream() throws IOException { if (this.ref == null) { // Don't configure upstream for detached HEAD return;/* w w w . ja v a2 s .c o m*/ } String remoteName = getRemoteName(); String fullRemoteBranchName = pushBranchPage.getFullRemoteReference(); String localBranchName = Repository.shortenRefName(this.ref.getName()); StoredConfig config = repository.getConfig(); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REMOTE, remoteName); config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_MERGE, fullRemoteBranchName); BranchRebaseMode rebaseMode = pushBranchPage.getUpstreamConfig(); if (rebaseMode != null) { config.setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName, ConfigConstants.CONFIG_KEY_REBASE, rebaseMode); } config.save(); }
From source file:org.eclipse.egit.ui.internal.push.PushBranchWizardTest.java
License:Open Source License
@Test public void pushWithRemoteUpstreamConfiguration() throws Exception { checkoutNewLocalBranch("foo"); // Existing configuration repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "foo", ConfigConstants.CONFIG_KEY_REMOTE, "fetch"); repository.getConfig().setString(ConfigConstants.CONFIG_BRANCH_SECTION, "foo", ConfigConstants.CONFIG_KEY_MERGE, "refs/heads/foo-on-remote"); repository.getConfig().setEnum(ConfigConstants.CONFIG_BRANCH_SECTION, "foo", ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.REBASE); // Make sure the repository does not have autosetuprebase set repository.getConfig().setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, false); PushBranchWizardTester wizard = PushBranchWizardTester.startWizard(selectProject(), "foo"); wizard.selectRemote("fetch"); wizard.assertBranchName("foo-on-remote"); wizard.assertRebaseSelected();/*from w ww . j a v a 2 s .c o m*/ assertFalse(wizard.isUpstreamConfigOverwriteWarningShown()); wizard.selectMerge(); assertTrue(wizard.isUpstreamConfigOverwriteWarningShown()); wizard.deselectConfigureUpstream(); assertFalse(wizard.isUpstreamConfigOverwriteWarningShown()); wizard.next(); wizard.finish(); ObjectId remoteId = remoteRepository.resolve("foo-on-remote"); ObjectId localId = repository.resolve("foo"); assertEquals(localId, remoteId); // Still configured assertBranchConfig("foo", "fetch", "refs/heads/foo-on-remote", "true"); }
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 w w. j a v a2s . c o 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)); }