Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Hohenegger2015-12-06 21:56:28 +0000
committerMatthias Sohn2015-12-30 00:55:41 +0000
commitf3c1041838e8e38ac1678f16e73476945bbedcd5 (patch)
tree8c7ea764b1815fec4e6b81d123238e065aa674d4 /org.eclipse.egit.gitflow.ui
parent4775d5d731de404ff062bc22a2d31fb78e17a89b (diff)
downloadegit-f3c1041838e8e38ac1678f16e73476945bbedcd5.tar.gz
egit-f3c1041838e8e38ac1678f16e73476945bbedcd5.tar.xz
egit-f3c1041838e8e38ac1678f16e73476945bbedcd5.zip
Minor refactoring: removed redundant getRepository()
Change-Id: I6fb6292c39960fdb9e5bf2025ca60c70e24788c6 Signed-off-by: Max Hohenegger <eclipse@hohenegger.eu>
Diffstat (limited to 'org.eclipse.egit.gitflow.ui')
-rw-r--r--org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/ReleaseStartHandler.java32
1 files changed, 2 insertions, 30 deletions
diff --git a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/ReleaseStartHandler.java b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/ReleaseStartHandler.java
index 9aae1fbb60..8a78ae6887 100644
--- a/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/ReleaseStartHandler.java
+++ b/org.eclipse.egit.gitflow.ui/src/org/eclipse/egit/gitflow/ui/internal/actions/ReleaseStartHandler.java
@@ -11,8 +11,6 @@ package org.eclipse.egit.gitflow.ui.internal.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.internal.job.JobUtil;
import org.eclipse.egit.gitflow.GitFlowRepository;
import org.eclipse.egit.gitflow.WrongGitFlowStateException;
@@ -20,18 +18,14 @@ import org.eclipse.egit.gitflow.op.ReleaseStartOperation;
import org.eclipse.egit.gitflow.ui.internal.JobFamilies;
import org.eclipse.egit.gitflow.ui.internal.UIText;
import org.eclipse.egit.gitflow.ui.internal.validation.ReleaseNameValidator;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.egit.ui.internal.selection.SelectionUtils;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
-import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.ui.history.IHistoryView;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
/**
@@ -80,11 +74,10 @@ public class ReleaseStartHandler extends AbstractHandler {
RevCommit plotCommit = (RevCommit) selection.getFirstElement();
return plotCommit.getName();
} else {
- Repository repository = getRepository(event);
- if (repository == null) {
+ GitFlowRepository gitFlowRepository = GitFlowHandlerUtil.getRepository(event);
+ if (gitFlowRepository == null) {
throw new ExecutionException(UIText.ReleaseStartHandler_startCommitCouldNotBeDetermined);
}
- GitFlowRepository gitFlowRepository = new GitFlowRepository(repository);
RevCommit head;
try {
head = gitFlowRepository.findHead();
@@ -94,25 +87,4 @@ public class ReleaseStartHandler extends AbstractHandler {
return head.getName();
}
}
-
- private @Nullable Repository getRepository(ExecutionEvent event)
- throws ExecutionException {
- PlatformObject firstElement;
- IStructuredSelection selection = (IStructuredSelection) HandlerUtil
- .getCurrentSelection(event);
- if (selection.getFirstElement() instanceof PlotCommit) {
- IWorkbenchPart ap = HandlerUtil.getActivePartChecked(event);
- if (ap instanceof IHistoryView) {
- firstElement = (PlatformObject) ((IHistoryView) ap)
- .getHistoryPage().getInput();
- } else {
- // This is unexpected
- return null;
- }
-
- } else {
- firstElement = (PlatformObject) selection.getFirstElement();
- }
- return Utils.getAdapter(firstElement, Repository.class);
- }
}

Back to the top