summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorAndré Dietisheim2012-09-04 16:39:41 (EDT)
committer Matthias Sohn2012-09-04 16:39:41 (EDT)
commitf1550b8293315b84b476a65953555102f7e8c6d5 (patch)
treecdd54016829be3faae5e77c2ac16fe9be375be47
parentbd37aa463fe373d01078519abbc9a271ec6b3d3c (diff)
downloadegit-f1550b8293315b84b476a65953555102f7e8c6d5.zip
egit-f1550b8293315b84b476a65953555102f7e8c6d5.tar.gz
egit-f1550b8293315b84b476a65953555102f7e8c6d5.tar.bz2
Allow users to push to upstream when committingrefs/changes/87/7487/5
I added a checkbox to the commit dialog that allows a user to commit and push to upstream in a single step. Bug: 330048 Change-Id: Ic5a9c42c2c5ab5e6ba86ee0e0098507f8cd31d9f Signed-off-by: Andre Dietisheim <adietish@redhat.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--.gitignore1
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java12
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitUI.java63
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java36
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties4
6 files changed, 115 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index eb5a316..90505ea 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
target
+.metadata
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
index dbed532..a88ae8b 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIPreferences.java
@@ -73,6 +73,8 @@ public class UIPreferences {
/** */
public final static String COMMIT_DIALOG_INCLUDE_UNTRACKED = "commit_dialog_include_untracked"; //$NON-NLS-1$
/** */
+ public final static String COMMIT_DIALOG_PUSH_UPSTREAM = "commit_dialog_push_upstream"; //$NON-NLS-1$
+ /** */
public final static String CHECKOUT_PROJECT_RESTORE = "restore_projects_on_checkout"; //$NON-NLS-1$
/** */
public final static String THEME_CommitGraphNormalFont = "org.eclipse.egit.ui.CommitGraphNormalFont"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index fc917b7..f37c39c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -1968,6 +1968,12 @@ public class UIText extends NLS {
public static String CommitDialog_Title;
/** */
+ public static String CommitDialog_PushSectionTitle;
+
+ /** */
+ public static String CommitDialog_PushUpstream;
+
+ /** */
public static String ConfigurationChecker_gitPrefixWarningMessage;
/** */
@@ -4408,6 +4414,12 @@ public class UIText extends NLS {
public static String CommitUI_commitFailed;
/** */
+ public static String CommitUI_pushFailedTitle;
+
+ /** */
+ public static String CommitUI_pushFailedMessage;
+
+ /** */
public static String EgitUiEditorUtils_openFailed;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitUI.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitUI.java
index 6e5cd7e..288bd61 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitUI.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/commit/CommitUI.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -35,28 +36,37 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.egit.core.EclipseGitProgressTransformer;
import org.eclipse.egit.core.IteratorService;
import org.eclipse.egit.core.op.CommitOperation;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
+import org.eclipse.egit.ui.UIPreferences;
import org.eclipse.egit.ui.UIText;
import org.eclipse.egit.ui.UIUtils;
import org.eclipse.egit.ui.internal.decorators.GitLightweightDecorator;
import org.eclipse.egit.ui.internal.dialogs.BasicConfigurationDialog;
import org.eclipse.egit.ui.internal.dialogs.CommitDialog;
import org.eclipse.egit.ui.internal.dialogs.CommitMessageComponentStateManager;
+import org.eclipse.egit.ui.internal.push.PushOperationUI;
+import org.eclipse.egit.ui.internal.push.PushWizard;
+import org.eclipse.egit.ui.internal.push.SimpleConfigurePushDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.IndexDiff;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -111,7 +121,7 @@ public class CommitUI {
this.preselectAll = preselectAll;
}
- /**
+ /**1
* Performs a commit
* @return true if a commit operation was triggered
*/
@@ -201,10 +211,51 @@ public class CommitUI {
commitOperation.setCommitAll(commitHelper.isMergedResolved);
if (commitHelper.isMergedResolved)
commitOperation.setRepository(repo);
- performCommit(repo, commitOperation, false);
+ Job commitJob = createCommitJob(repo, commitOperation, false);
+ if (commitDialog.isPushEnabled())
+ pushWhenFinished(commitJob);
+
+ commitJob.schedule();
+
return true;
}
+ private void pushWhenFinished(Job commitJob) {
+ commitJob.addJobChangeListener(new JobChangeAdapter() {
+
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (event.getResult().getSeverity() == IStatus.ERROR)
+ return;
+ RemoteConfig config = SimpleConfigurePushDialog
+ .getConfiguredRemote(repo);
+ if (config == null) {
+ Display.getDefault().syncExec(new Runnable() {
+
+ public void run() {
+ try {
+ WizardDialog wizardDialog = new WizardDialog(
+ shell, new PushWizard(repo));
+ wizardDialog.setHelpAvailable(true);
+ wizardDialog.open();
+ } catch (URISyntaxException e) {
+ Activator.handleError(NLS.bind(
+ UIText.CommitUI_pushFailedMessage, e),
+ e, true);
+ }
+ }
+ });
+ } else {
+ int timeout = Activator.getDefault().getPreferenceStore()
+ .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
+ PushOperationUI op = new PushOperationUI(repo, config
+ .getName(), timeout, false);
+ op.start();
+ }
+ }
+ });
+ }
+
/**
* Uses a Job to perform the given CommitOperation
* @param repository
@@ -213,6 +264,12 @@ public class CommitUI {
*/
public static void performCommit(final Repository repository,
final CommitOperation commitOperation, final boolean openNewCommit) {
+ Job job = createCommitJob(repository, commitOperation, openNewCommit);
+ job.schedule();
+ }
+
+ private static Job createCommitJob(final Repository repository,
+ final CommitOperation commitOperation, final boolean openNewCommit) {
String jobname = UIText.CommitAction_CommittingChanges;
Job job = new Job(jobname) {
@Override
@@ -250,7 +307,7 @@ public class CommitUI {
};
job.setUser(true);
- job.schedule();
+ return job;
}
private static void openCommit(final Repository repository,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
index 026a9af..6c24f22 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/CommitDialog.java
@@ -356,6 +356,8 @@ public class CommitDialog extends TitleAreaDialog {
private Repository repository;
+ private boolean pushEnabled = false;
+
/**
* @param parentShell
*/
@@ -509,6 +511,14 @@ public class CommitDialog extends TitleAreaDialog {
return createChangeId;
}
+ /**
+ * Returns whether we are pushing after the commit
+ * @return pushing
+ */
+ public boolean isPushEnabled() {
+ return pushEnabled;
+ }
+
@Override
protected void createButtonsForButtonBar(Composite parent) {
toolkit.adapt(parent, false, false);
@@ -895,6 +905,32 @@ public class CommitDialog extends TitleAreaDialog {
}
}
+ Section pushSection = toolkit.createSection(container,
+ ExpandableComposite.TITLE_BAR
+ | ExpandableComposite.CLIENT_INDENT);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(pushSection);
+ Composite pushArea = toolkit.createComposite(pushSection);
+ pushSection.setClient(pushArea);
+ toolkit.paintBordersFor(pushArea);
+ GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2)
+ .applyTo(pushArea);
+ pushSection.setText(UIText.CommitDialog_PushSectionTitle);
+ final Button pushCheckbox = toolkit.createButton(pushArea,
+ UIText.CommitDialog_PushUpstream, SWT.CHECK);
+ pushCheckbox.setSelection(getPreferenceStore().getBoolean(
+ UIPreferences.COMMIT_DIALOG_PUSH_UPSTREAM));
+ pushEnabled = getPreferenceStore().getBoolean(
+ UIPreferences.COMMIT_DIALOG_PUSH_UPSTREAM);
+ pushCheckbox.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ pushEnabled = pushCheckbox.getSelection();
+ getPreferenceStore().setValue(
+ UIPreferences.COMMIT_DIALOG_PUSH_UPSTREAM, pushEnabled);
+ }
+ });
+
applyDialogFont(container);
statCol.pack();
resourceCol.pack();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 9086eb4..b6a9694 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -683,6 +683,8 @@ CommitDialog_MessageNoFilesSelected=Select one or more files to commit
CommitDialog_Path=Path
CommitDialog_Title=Commit Changes to Git Repository
CommitDialog_WrongTypeOfCommitMessageProvider=The extension used as CommitMessageProvider has the wrong type (it must implement org.eclipse.egit.ui.ICommitMessageProvider)
+CommitDialog_PushSectionTitle=Push
+CommitDialog_PushUpstream=&Push the changes to upstream
SpellcheckableMessageArea_redo=Redo
SpellcheckableMessageArea_showWhitespace=Show &Whitespace Characters
@@ -1350,6 +1352,8 @@ CommitSelectionDialog_TaskSearching=Searching commits
CommitSelectionDialog_Title=Open Git Commit
CommitSelectionDialog_WindowTitle=Select a Commit
CommitUI_commitFailed=Commit failed
+CommitUI_pushFailedTitle=Push failed
+CommitUI_pushFailedMessage=Could not push {0} to {1}: {2}
GitSynchronizeWizard_synchronize=Synchronize