diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 4171998..86dea8a 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -2,7 +2,7 @@ Git Flow Integration Gitflow Git Flow Integration - 0.6.3 + 0.6.4 VCS Integration Opher Vishnia @@ -10,7 +10,7 @@ com.intellij.tasks Git4Idea - + 0){ //todo handle case of multiple vcs handlers @@ -100,19 +106,38 @@ public void commit() { final GitflowBranchUtil.ComboEntry selectedFeatureBaseBranch = (GitflowBranchUtil.ComboEntry) featureBaseBranch.getModel().getSelectedItem(); final GitflowBranchUtil.ComboEntry selectedHotfixBaseBranch = (GitflowBranchUtil.ComboEntry) hotfixBaseBranch.getModel().getSelectedItem(); - GitflowAction action; - if (startFeatureRadioButton.isSelected()) { - action = new StartFeatureAction(myRepo); - action.runAction(myProject, selectedFeatureBaseBranch.getBranchName(), featureName.getText()); - gitflowState.setTaskBranch(currentTask, GitflowConfigUtil.getFeaturePrefix(myProject, myRepo) + featureName.getText()); + final String branchName = GitflowConfigUtil.getFeaturePrefix(myProject, myRepo) + featureName.getText(); + attachTaskAndRunAction(new StartFeatureAction(myRepo), selectedFeatureBaseBranch.getBranchName(), branchName); } else if (startHotfixRadioButton.isSelected()) { - action = new StartHotfixAction(myRepo); - action.runAction(myProject, selectedHotfixBaseBranch.getBranchName(), hotfixName.getText()); - gitflowState.setTaskBranch(currentTask, GitflowConfigUtil.getHotfixPrefix(myProject, myRepo) + hotfixName.getText()); + final String branchName = GitflowConfigUtil.getHotfixPrefix(myProject, myRepo) + hotfixName.getText(); + attachTaskAndRunAction(new StartHotfixAction(myRepo), selectedHotfixBaseBranch.getBranchName(), branchName); } + } + /** + * @param action instance of GitflowAction + * @param baseBranchName Branch name of the branch the new one is based on + * @param fullBranchName Branch name with feature/hotfix prefix for saving to task + */ + private void attachTaskAndRunAction(GitflowAction action, String baseBranchName, final String fullBranchName) { + final String branchName = gitflowBranchUtil.stripFullBranchName(fullBranchName); + + //Create new branch / checkout branch + action.runAction(myProject, baseBranchName, branchName, new Runnable() { + @Override + public void run() { + final TaskInfo[] next = {new TaskInfo(fullBranchName, Collections.singleton(myRepo.getPresentableUrl()))}; + final LocalTask localTask = myTaskManager.getActiveTask(); + + //Add branch to task + TaskManagerImpl.addBranches(localTask, next, false); + + //maps branch to task + gitflowState.setTaskBranch(currentTask, fullBranchName); + } + }); } @Override