Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-02-11 09:02:33 +0000
committerEike Stepper2012-02-11 09:02:33 +0000
commit4ea5ef72c04f4fbfde9ceb758f679c3a6e8f7102 (patch)
tree082be830329bba9debb5a21edde73d9157c150c2 /plugins/org.eclipse.emf.cdo.releng.gitbash/src
parent5bba0148931feee992f47bfef5ffa54ecbc2235d (diff)
downloadcdo-4ea5ef72c04f4fbfde9ceb758f679c3a6e8f7102.tar.gz
cdo-4ea5ef72c04f4fbfde9ceb758f679c3a6e8f7102.tar.xz
cdo-4ea5ef72c04f4fbfde9ceb758f679c3a6e8f7102.zip
Added GitAddAll and GitResetHard
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.releng.gitbash/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAction.java)13
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/Activator.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitApplyAction.java (renamed from plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/ApplyPatchToGitAction.java)33
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBash.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java31
7 files changed, 114 insertions, 46 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java
index 67d7b1e82b..3e6cf322e0 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/AbstractRepositoryAction.java
@@ -15,6 +15,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
@@ -23,13 +24,13 @@ import java.io.File;
/**
* @author Eike Stepper
*/
-public class GitAction implements IObjectActionDelegate
+public abstract class AbstractRepositoryAction implements IObjectActionDelegate
{
private IWorkbenchPart targetPart;
private Repository repository;
- public GitAction()
+ public AbstractRepositoryAction()
{
}
@@ -57,13 +58,9 @@ public class GitAction implements IObjectActionDelegate
{
if (repository != null)
{
- String gitBash = GitBash.getExecutable(targetPart.getSite().getShell());
-
try
{
- File workTree = repository.getWorkTree();
- Runtime.getRuntime().exec(
- "cmd /c cd \"" + workTree.getAbsolutePath() + "\" && start cmd.exe /c \"" + gitBash + "\" --login -i");
+ run(targetPart.getSite().getShell(), repository.getWorkTree());
}
catch (Exception ex)
{
@@ -71,4 +68,6 @@ public class GitAction implements IObjectActionDelegate
}
}
}
+
+ protected abstract void run(Shell shell, File workTree) throws Exception;
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/Activator.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/Activator.java
index da313a169c..69bd72b66e 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/Activator.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/Activator.java
@@ -47,7 +47,12 @@ public class Activator extends AbstractUIPlugin
public static void log(String message)
{
- plugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, message));
+ log(message, IStatus.INFO);
+ }
+
+ protected static void log(String message, int severity)
+ {
+ plugin.getLog().log(new Status(severity, PLUGIN_ID, message));
}
public static void log(IStatus status)
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java
new file mode 100644
index 0000000000..aba2aef32e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitAddAllAction.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitAddAllAction extends AbstractRepositoryAction
+{
+ public GitAddAllAction()
+ {
+ }
+
+ @Override
+ protected void run(Shell shell, File workTree) throws Exception
+ {
+ GitBash.executeCommand(shell, workTree, "git add --all");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/ApplyPatchToGitAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitApplyAction.java
index 0e1a482b38..bcbb6163f6 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/ApplyPatchToGitAction.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitApplyAction.java
@@ -33,7 +33,6 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
@@ -45,7 +44,7 @@ import java.util.List;
/**
* @author Eike Stepper
*/
-public class ApplyPatchToGitAction extends BaseSelectionListenerAction implements IObjectActionDelegate, IMenuCreator
+public class GitApplyAction extends BaseSelectionListenerAction implements IObjectActionDelegate, IMenuCreator
{
private IWorkbenchPart targetPart;
@@ -53,12 +52,12 @@ public class ApplyPatchToGitAction extends BaseSelectionListenerAction implement
private Menu dropDownMenu;
- public ApplyPatchToGitAction()
+ public GitApplyAction()
{
super("Adjust and Apply Patch");
}
- protected ApplyPatchToGitAction(String text)
+ protected GitApplyAction(String text)
{
super(text);
}
@@ -249,30 +248,4 @@ public class ApplyPatchToGitAction extends BaseSelectionListenerAction implement
}
}
}
-
- public static void main(String[] args) throws IOException, InterruptedException
- {
- File workTree = new File("C:\\develop\\git\\cdo");
- String gitBash = "C:\\Program Files (x86)\\Git\\bin\\sh.exe";
-
- ProcessBuilder builder = new ProcessBuilder(gitBash, "--login", "-c",
- "git apply C:/develop/patches/git-patch-357613.txt");
- builder.directory(workTree);
- builder.redirectErrorStream(true);
-
- Process process = builder.start();
-
- // String prefix = "cmd /c cd \"" + workTree.getAbsolutePath() + "\" && \"" + gitBash + "\"";
- // String command = "apply C:/develop/patches/git-patch-357613.txt";
- // Process process = Runtime.getRuntime().exec(prefix + " " + command);
- BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
-
- String line;
- while ((line = reader.readLine()) != null)
- {
- System.out.println(line);
- }
-
- System.out.println(process.waitFor());
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBash.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBash.java
index f7acb6a14c..536e7489da 100644
--- a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBash.java
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBash.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.releng.gitbash;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.swt.widgets.Shell;
@@ -85,14 +86,9 @@ public class GitBash
}
int exitValue = process.waitFor();
- if (exitValue == 0)
- {
- Activator.log("Command '" + command + "' executed successfully\n" + output);
- }
- else
- {
- throw new RuntimeException("Command '" + command + "' failed: " + exitValue + "\n" + output);
- }
+ String message = exitValue == 0 ? "executed successfully" : "failed: " + exitValue;
+ int severity = exitValue == 0 ? IStatus.INFO : IStatus.ERROR;
+ Activator.log("Command '" + command + "' " + message + "\n" + output, severity);
}
catch (RuntimeException ex)
{
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java
new file mode 100644
index 0000000000..3f3f4f60af
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitBashAction.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitBashAction extends AbstractRepositoryAction
+{
+ public GitBashAction()
+ {
+ }
+
+ @Override
+ protected void run(Shell shell, File workTree) throws Exception
+ {
+ String gitBash = GitBash.getExecutable(shell);
+ Runtime.getRuntime().exec(
+ "cmd /c cd \"" + workTree.getAbsolutePath() + "\" && start cmd.exe /c \"" + gitBash + "\" --login -i");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java
new file mode 100644
index 0000000000..0695333dab
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.releng.gitbash/src/org/eclipse/emf/cdo/releng/gitbash/GitResetHardAction.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.releng.gitbash;
+
+import org.eclipse.swt.widgets.Shell;
+
+import java.io.File;
+
+/**
+ * @author Eike Stepper
+ */
+public class GitResetHardAction extends AbstractRepositoryAction
+{
+ public GitResetHardAction()
+ {
+ }
+
+ @Override
+ protected void run(Shell shell, File workTree) throws Exception
+ {
+ GitBash.executeCommand(shell, workTree, "git reset --hard");
+ }
+}

Back to the top