diff options
author | Matthias Sohn | 2016-02-04 22:32:45 +0000 |
---|---|---|
committer | Thomas Wolf | 2016-02-13 13:46:56 +0000 |
commit | 220225fe8d9195e3c686d290cc96d230e2005fde (patch) | |
tree | 69f3056eb12c97b07d6f33f42c2154d58398f9c4 /org.eclipse.egit.ui.test | |
parent | c6a421bcccd8b07382af86e00781f03e2118c00b (diff) | |
download | egit-220225fe8d9195e3c686d290cc96d230e2005fde.tar.gz egit-220225fe8d9195e3c686d290cc96d230e2005fde.tar.xz egit-220225fe8d9195e3c686d290cc96d230e2005fde.zip |
Ensure "Push HEAD..." action is enabled also when HEAD is detached
Fixing a regression introduced by https://git.eclipse.org/r/#/c/63972/
Push should be enabled if HEAD directly or indirectly refers to a
commit.
Bug: 487078
Change-Id: I13a28252472957ac172fa91fe89406e736f6a34a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui.test')
3 files changed, 49 insertions, 4 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java index a01f75472c..23a51e358d 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTest.java @@ -19,7 +19,10 @@ import org.eclipse.egit.core.op.CreateLocalBranchOperation; import org.eclipse.egit.core.op.CreateLocalBranchOperation.UpstreamConfig; import org.eclipse.egit.ui.common.LocalRepositoryTestCase; import org.eclipse.egit.ui.test.TestUtil; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.ConfigConstants; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; @@ -61,6 +64,23 @@ public class PushBranchWizardTest extends LocalRepositoryTestCase { } @Test + public void pushHeadToExistingRemote() throws Exception { + try (Git git = new Git(repository)) { + AnyObjectId head = repository.resolve(Constants.HEAD); + git.checkout().setName(head.name()).call(); + } + + PushBranchWizardTester wizard = PushBranchWizardTester + .startWizard(selectProject(), Constants.HEAD); + wizard.selectRemote("fetch"); + wizard.enterBranchName("foo"); + wizard.next(); + wizard.finish(); + + assertBranchPushed("foo", remoteRepository); + } + + @Test public void pushToExistingRemoteAndSetRebase() throws Exception { checkoutNewLocalBranch("bar"); diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTester.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTester.java index 1667c2e824..9acb83eb6a 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTester.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/push/PushBranchWizardTester.java @@ -19,6 +19,7 @@ import org.eclipse.egit.ui.internal.UIText; import org.eclipse.egit.ui.test.ContextMenuHelper; import org.eclipse.egit.ui.test.JobJoiner; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jgit.lib.Constants; import org.eclipse.osgi.util.NLS; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.SWTBot; @@ -32,16 +33,19 @@ public class PushBranchWizardTester { public static PushBranchWizardTester startWizard(SWTBotTree projectTree, String branchName) { - String pushBranchMenu = NLS - .bind(UIText.PushMenu_PushBranch, branchName); + String pushBranchMenu = branchName.equals(Constants.HEAD) + ? UIText.PushMenu_PushHEAD + : NLS.bind(UIText.PushMenu_PushBranch, branchName); ContextMenuHelper.clickContextMenu(projectTree, "Team", pushBranchMenu); return forBranchName(branchName); } public static PushBranchWizardTester forBranchName(String branchName) { SWTWorkbenchBot bot = new SWTWorkbenchBot(); - String title = MessageFormat.format( - UIText.PushBranchWizard_WindowTitle, branchName); + String title = branchName.equals(Constants.HEAD) + ? UIText.PushCommitHandler_pushCommitTitle + : MessageFormat.format(UIText.PushBranchWizard_WindowTitle, + branchName); SWTBot wizard = bot.shell(title).bot(); return new PushBranchWizardTester(wizard); } diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java index 77ec5cf2f2..85a4a38349 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewFetchAndPushTest.java @@ -11,6 +11,7 @@ package org.eclipse.egit.ui.view.repositories; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.File; @@ -175,6 +176,26 @@ public class GitRepositoriesViewFetchAndPushTest extends } @Test + public void testNoHeadSimplePushDisabled() throws Exception { + Repository emptyRepo = createLocalTestRepository("empty"); + File gitDir = emptyRepo.getDirectory(); + Activator.getDefault().getRepositoryUtil() + .addConfiguredRepository(gitDir); + GitRepositoriesViewTestUtils viewUtil = new GitRepositoriesViewTestUtils(); + SWTBotTree tree = getOrOpenView().bot().tree(); + SWTBotTreeItem repoItem = viewUtil.getRootItem(tree, gitDir); + repoItem.select(); + boolean enabled = ContextMenuHelper.isContextMenuItemEnabled(tree, + NLS.bind(UIText.PushMenu_PushBranch, "master")); + assertFalse("Push branch should be disabled if there is no HEAD", + enabled); + enabled = ContextMenuHelper.isContextMenuItemEnabled(tree, + util.getPluginLocalizedValue("PushToUpstreamCommand.label")); + assertFalse("Push to upstream should be disabled if there is no HEAD", + enabled); + } + + @Test public void testFetchFromOriginFetchNode() throws Exception { testFetchFromOrigin(false); } |