Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Hohenegger2019-07-28 15:18:38 +0000
committerMichael Keppler2019-08-21 06:12:15 +0000
commitf9c82928f45f5e9ab33ab04a08904e1b6d2ebfa6 (patch)
tree7cfd002d9d36482b12c3c0ea28ee65ecc5d3cf27 /org.eclipse.egit.ui.test
parenta3cbbff0ea6af88f8b2db463633cdd0fe9c9b026 (diff)
downloadegit-f9c82928f45f5e9ab33ab04a08904e1b6d2ebfa6.tar.gz
egit-f9c82928f45f5e9ab33ab04a08904e1b6d2ebfa6.tar.xz
egit-f9c82928f45f5e9ab33ab04a08904e1b6d2ebfa6.zip
Fix silent failure on conflicting checkout after branch creation.
* Minor changes in BranchOperationUI to re-use checkout result handling. * Add UI test because the issue is tedious to reproduce, and depends on proper synchronization with the Job and the Display thread. Bug 549612 Change-Id: I616b975f5eff881c6cc3455649ec7dd7a9bd293f Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
Diffstat (limited to 'org.eclipse.egit.ui.test')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java23
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java43
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureRebaseHandlerTest.java2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartCheckoutConflictTest.java43
4 files changed, 83 insertions, 28 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java
index 83dba055a7..5529152402 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractFeatureFinishHandlerTest.java
@@ -13,8 +13,6 @@ package org.eclipse.egit.ui.gitflow;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import static org.junit.Assert.assertFalse;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.egit.core.op.BranchOperation;
import org.eclipse.egit.gitflow.ui.Activator;
import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
import org.eclipse.egit.gitflow.ui.internal.UIText;
@@ -55,23 +53,6 @@ public abstract class AbstractFeatureFinishHandlerTest extends AbstractGitflowHa
abstract protected void selectOptions();
@Override
- protected void createFeature(String featureName) {
- 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("TeamGitFlowFeatureStart.name", false, Activator.getDefault().getBundle()) };
-
- ContextMenuHelper.clickContextMenu(projectExplorerTree, menuPath);
-
- bot.waitUntil(shellIsActive(UIText.FeatureStartHandler_provideFeatureName));
- bot.text().setText(featureName);
- bot.button(UIText.StartDialog_ButtonOK).click();
- bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
- }
-
- @Override
public void checkoutFeature(String featureName) {
final SWTBotTree projectExplorerTree = TestUtil.getExplorerTree();
getProjectItem(projectExplorerTree, PROJ1).select();
@@ -94,8 +75,4 @@ public abstract class AbstractFeatureFinishHandlerTest extends AbstractGitflowHa
bot.button(UIText.FeatureCheckoutHandler_ButtonOK).click();
bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
}
-
- protected 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/AbstractGitflowHandlerTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/AbstractGitflowHandlerTest.java
index 56b7222730..4a5c2f6f43 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
@@ -13,17 +13,22 @@ package org.eclipse.egit.ui.gitflow;
import static org.eclipse.egit.gitflow.ui.internal.UIPreferences.FEATURE_FINISH_KEEP_BRANCH;
import static org.eclipse.egit.gitflow.ui.internal.UIPreferences.FEATURE_FINISH_SQUASH;
import static org.eclipse.jgit.lib.Constants.R_HEADS;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
import java.io.File;
import java.io.IOException;
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;
+import org.eclipse.egit.gitflow.ui.internal.UIText;
import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jgit.api.CommitCommand;
@@ -31,6 +36,7 @@ import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.AbortedByHookException;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.NoFilepatternException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.api.errors.NoMessageException;
import org.eclipse.jgit.api.errors.UnmergedPathsException;
@@ -38,7 +44,9 @@ import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
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.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@@ -77,16 +85,22 @@ public abstract class AbstractGitflowHandlerTest extends LocalRepositoryTestCase
protected RevCommit setContentAddAndCommit(String newContent) throws Exception, GitAPIException, NoHeadException,
NoMessageException, UnmergedPathsException, ConcurrentRefUpdateException, WrongRepositoryStateException,
AbortedByHookException, IOException {
- setTestFileContent(newContent);
-
- Git git = Git.wrap(repository);
- git.add().addFilepattern(".").call();
+ Git git = setContentAndStage(newContent);
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 Git setContentAndStage(String newContent)
+ throws Exception, GitAPIException, NoFilepatternException {
+ setTestFileContent(newContent);
+
+ Git git = Git.wrap(repository);
+ git.add().addFilepattern(".").call();
+ return git;
+ }
+
protected void createFeature(String featureName) throws CoreException {
new FeatureStartOperation(new GitFlowRepository(repository),
featureName).execute(null);
@@ -104,4 +118,25 @@ public abstract class AbstractGitflowHandlerTest extends LocalRepositoryTestCase
protected void init() throws CoreException {
new InitOperation(repository).execute(null);
}
+
+ protected void checkoutBranch(String branchToCheckout)
+ throws CoreException {
+ new BranchOperation(repository, branchToCheckout).execute(null);
+ }
+
+ protected void createFeatureUi(String featureName) {
+ 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("TeamGitFlowFeatureStart.name", false, Activator.getDefault().getBundle()) };
+
+ ContextMenuHelper.clickContextMenu(projectExplorerTree, menuPath);
+
+ bot.waitUntil(shellIsActive(UIText.FeatureStartHandler_provideFeatureName));
+ bot.text().setText(featureName);
+ bot.button(UIText.StartDialog_ButtonOK).click();
+ bot.waitUntil(Conditions.waitForJobs(JobFamilies.GITFLOW_FAMILY, "Git flow jobs"));
+ }
}
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 4fac5011fe..aef233e633 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
@@ -107,7 +107,7 @@ public class FeatureRebaseHandlerTest extends AbstractGitflowHandlerTest {
new FeatureCheckoutOperation(new GitFlowRepository(repository), featureName).execute(null);
}
- private void checkoutBranch(String branchToCheckout) throws CoreException {
+ protected 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/FeatureStartCheckoutConflictTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartCheckoutConflictTest.java
new file mode 100644
index 0000000000..bf00174f96
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/gitflow/FeatureStartCheckoutConflictTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (C) 2019, 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 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package org.eclipse.egit.ui.gitflow;
+
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
+
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for the Team->Gitflow->Feature Start action, when a conflict occurs on
+ * checkout, after the branch has been created.
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class FeatureStartCheckoutConflictTest
+ extends AbstractGitflowHandlerTest {
+
+ @Test
+ public void testFeatureStart() throws Exception {
+ init();
+
+ createFeature(FEATURE_NAME);
+ checkoutBranch(DEVELOP);
+ setContentAddAndCommit("foo");
+ checkoutFeature(FEATURE_NAME);
+ setContentAndStage("bar");
+ setTestFileContent("fnord");
+ createFeatureUi("myOtherFeature");
+
+ bot.waitUntil(shellIsActive(UIText.BranchResultDialog_CheckoutConflictsTitle));
+ bot.button(UIText.BranchResultDialog_buttonDiscardChanges).click();
+ }
+}

Back to the top