Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Hohenegger2015-07-05 21:48:14 +0000
committerMatthias Sohn2015-08-16 01:08:37 +0000
commita8a7faf8977557e539dfa9cab5b096f0bbad9efd (patch)
treefbe7a8ed819cccf28b6f9cc26321c950faac7852 /org.eclipse.egit.ui.test
parent09e583fc25773a474b4a8485a42089437f262c68 (diff)
downloadegit-a8a7faf8977557e539dfa9cab5b096f0bbad9efd.tar.gz
egit-a8a7faf8977557e539dfa9cab5b096f0bbad9efd.tar.xz
egit-a8a7faf8977557e539dfa9cab5b096f0bbad9efd.zip
[gitflow] Feature finish squash should allow changing the commit message
- open standard commit message edit dialog to change squashed message - duplicated stripCommentLines(..) from RebaseCommand to delete comments - added UI test for feature finish squash - pulled up some redundant test code Bug: 473550 Change-Id: I028a05f21c7ca3f3a501dba160a3ed4ff035c87b Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java21
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java120
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java8
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java6
4 files changed, 145 insertions, 10 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
index 4b5257a921..4c41e63923 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
@@ -11,7 +11,13 @@ package org.eclipse.egit.ui.gitflow;
import java.io.File;
import java.io.IOException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.gitflow.op.FeatureCheckoutOperation;
+import org.eclipse.egit.gitflow.op.FeatureStartOperation;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.AbortedByHookException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
@@ -49,6 +55,19 @@ public abstract class AbstractGitflowHandlerTest extends LocalRepositoryTestCase
Git git = Git.wrap(repository);
git.add().addFilepattern(".").call();
- return git.commit().setMessage(newContent).call();
+ CommitCommand commit = git.commit().setMessage(newContent);
+ commit.setAuthor(TestUtil.TESTCOMMITTER_NAME, TestUtil.TESTCOMMITTER_EMAIL);
+ commit.setCommitter(TestUtil.TESTCOMMITTER_NAME, TestUtil.TESTCOMMITTER_EMAIL);
+ return commit.call();
+ }
+
+ protected void createFeature(String featureName) throws CoreException {
+ new FeatureStartOperation(new GitFlowRepository(repository),
+ featureName).execute(null);
+ }
+
+ protected void checkoutFeature(String featureName) throws CoreException {
+ new FeatureCheckoutOperation(new GitFlowRepository(repository),
+ featureName).execute(null);
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
new file mode 100644
index 0000000000..0154d82713
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureFinishSquashHandlerTest.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (C) 2015, Max Hohenegger <eclipse@hohenegger.eu>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.gitflow;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.egit.core.op.BranchOperation;
+import org.eclipse.egit.gitflow.GitFlowRepository;
+import org.eclipse.egit.gitflow.op.InitOperation;
+import org.eclipse.egit.gitflow.ui.Activator;
+import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
+import org.eclipse.egit.gitflow.ui.internal.UIText;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
+import org.eclipse.egit.ui.test.TestUtil;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.NoHeadException;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.PlatformUI;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow->Feature Finish action with squash option
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class FeatureFinishSquashHandlerTest extends AbstractGitflowHandlerTest {
+
+ private static final String SQUASHED_COMMENT_SUMMARY = "Hello World";
+
+ @Test
+ public void testFeatureFinishSquash() throws Exception {
+ int expectedCommitCount = 2;
+
+ init();
+
+ setContentAddAndCommit("bar");
+ expectedCommitCount++;
+
+ createFeature(FEATURE_NAME);
+ RevCommit commit1 = setContentAddAndCommit("commit 1");
+ expectedCommitCount++;
+ RevCommit commit2 = setContentAddAndCommit("commit 2");
+ expectedCommitCount++;
+
+ checkoutBranch(DEVELOP);
+
+ checkoutFeature(FEATURE_NAME);
+
+ finishFeature();
+ expectedCommitCount--;
+
+ RevCommit developHead = new GitFlowRepository(repository).findHead();
+ assertNotEquals(developHead, commit1);
+ assertNotEquals(developHead, commit2);
+
+ assertEquals(expectedCommitCount, countCommits());
+
+ assertTrue(developHead.getFullMessage().startsWith(
+ SQUASHED_COMMENT_SUMMARY));
+ }
+
+ private int countCommits() throws GitAPIException, NoHeadException,
+ IOException {
+ Iterable<RevCommit> commits = Git.wrap(repository).log().all().call();
+ Iterator<RevCommit> iterator = commits.iterator();
+ int count = 0;
+
+ while (iterator.hasNext()) {
+ iterator.next();
+ count++;
+ }
+ return count;
+ }
+
+ private void finishFeature() {
+ final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
+ getProjectItem(projectExplorerTree, PROJ1).select();
+ final String[] menuPath = new String[] {
+ util.getPluginLocalizedValue("TeamMenu.label"),
+ util.getPluginLocalizedValue("TeamGitFlowMenu.name", false, Activator.getDefault().getBundle()),
+ util.getPluginLocalizedValue("TeamGitFlowFeatureFinish.name", false, Activator.getDefault().getBundle()) };
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ ContextMenuHelper.clickContextMenuSync(projectExplorerTree, menuPath);
+ }
+ });
+ bot.checkBox(UIText.FinishFeatureDialog_squashCheck).click();
+ bot.button("OK").click();
+ int firstLine = 0;
+ bot.styledText().selectLine(firstLine);
+ bot.styledText().typeText(SQUASHED_COMMENT_SUMMARY);
+ bot.button("OK").click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
+
+ private void init() throws CoreException {
+ new InitOperation(repository).execute(null);
+ }
+
+ private void checkoutBranch(String branchToCheckout) throws CoreException {
+ new BranchOperation(repository, branchToCheckout).execute(null);
+ }
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java
index feeed0d2b4..1ff34415b8 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java
@@ -14,7 +14,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.op.FeatureCheckoutOperation;
-import org.eclipse.egit.gitflow.op.FeatureStartOperation;
import org.eclipse.egit.gitflow.op.InitOperation;
import org.eclipse.egit.gitflow.ui.Activator;
import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
@@ -104,12 +103,7 @@ public class FeatureRebaseHandlerTest extends AbstractGitflowHandlerTest {
new InitOperation(repository).execute(null);
}
- private void createFeature(String featureName) throws CoreException {
- new FeatureStartOperation(new GitFlowRepository(repository),
- featureName).execute(null);
- }
-
- private void checkoutFeature(String featureName) throws CoreException {
+ protected void checkoutFeature(String featureName) throws CoreException {
new FeatureCheckoutOperation(new GitFlowRepository(repository), featureName).execute(null);
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
index ad68b49b98..857e9923e2 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartFinishHandlerTest.java
@@ -74,7 +74,8 @@ public class FeatureStartFinishHandlerTest extends AbstractGitflowHandlerTest {
new InitOperation(repository).execute(null);
}
- private void createFeature(String featureName) {
+ @Override
+ protected void createFeature(String featureName) {
final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
getProjectItem(projectExplorerTree, PROJ1).select();
final String[] menuPath = new String[] {
@@ -95,7 +96,8 @@ public class FeatureStartFinishHandlerTest extends AbstractGitflowHandlerTest {
bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
}
- private void checkoutFeature(String featureName) {
+ @Override
+ public void checkoutFeature(String featureName) {
final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
getProjectItem(projectExplorerTree, PROJ1).select();
final String[] menuPath = new String[] {

Back to the top