Skip to content

Commit

Permalink
Merge branch 'release/0.6.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Mar 25, 2018
2 parents 583b912 + 6adaccf commit a211795
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 46 deletions.
4 changes: 2 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<name>Git Flow Integration</name>
<id>Gitflow</id>
<description>Git Flow Integration</description>
<version>0.6.3</version>
<version>0.6.4</version>
<category>VCS Integration</category>
<vendor url="http://www.opherv.com">Opher Vishnia</vendor>

<depends>com.intellij.modules.vcs</depends>
<depends>com.intellij.tasks</depends>
<depends>Git4Idea</depends>

<idea-version since-build="162.0" until-build="173.*"/>
<idea-version since-build="162.0" until-build="181.*"/>

<actions>
<action id="Gitflow.OpenGitflowPopup" class="gitflow.actions.OpenGitflowPopup"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ I have worked hard on this plugin on my spare time. If you feel it is useful to
## License

This plugin is under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html).
Copyright 2013-2016, Opher Vishnia.
Copyright 2013-2018, Opher Vishnia.


4 changes: 4 additions & 0 deletions src/gitflow/GitInitLineHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
import java.io.IOException;
import java.io.OutputStreamWriter;

import git4idea.GitVcs;
import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;


public class GitInitLineHandler extends GitLineHandler {
@NotNull private final GitVcs myVcs;

private BufferedWriter writer;
GitflowInitOptions _initOptions;

public GitInitLineHandler(GitflowInitOptions initOptions, @NotNull Project project, @NotNull VirtualFile vcsRoot, @NotNull GitCommand command) {
super(project, vcsRoot, command);
myVcs = GitVcs.getInstance(project);
_initOptions = initOptions;
}

Expand Down
12 changes: 6 additions & 6 deletions src/gitflow/GitflowBranchUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ public ComboBoxModel createBranchComboModel(String defaultBranch) {

/**
* Strip a full branch name from its gitflow prefix
* @param taskFullBranchName full name of the branch (e.g. 'feature/hello');
* @param fullBranchName full name of the branch (e.g. 'feature/hello');
* @return the branch name, prefix free (e.g. 'hello')
*/
public String stripFullBranchName(String taskFullBranchName) {
if (taskFullBranchName.startsWith(prefixFeature)){
return taskFullBranchName.substring(prefixFeature.length(), taskFullBranchName.length());
public String stripFullBranchName(String fullBranchName) {
if (fullBranchName.startsWith(prefixFeature)){
return fullBranchName.substring(prefixFeature.length(), fullBranchName.length());
}
else if (taskFullBranchName.startsWith(prefixHotfix)){
return taskFullBranchName.substring(prefixHotfix.length(), taskFullBranchName.length());
else if (fullBranchName.startsWith(prefixHotfix)){
return fullBranchName.substring(prefixHotfix.length(), fullBranchName.length());
}
else{
return null;
Expand Down
5 changes: 1 addition & 4 deletions src/gitflow/actions/FinishFeatureAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vcs.VcsException;
import git4idea.branch.GitBranchUtil;
import git4idea.commands.GitCommandResult;
import git4idea.merge.GitMerger;
import git4idea.repo.GitRepository;
import gitflow.GitflowConfigUtil;
import gitflow.ui.NotifyUtil;
Expand Down Expand Up @@ -54,7 +51,7 @@ public void actionPerformed(AnActionEvent e) {
}

public void runAction(final Project project, final String featureName){
super.runAction(project, null, featureName);
super.runAction(project, null, featureName, null);

final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);
final FinishFeatureAction that = this;
Expand Down
2 changes: 1 addition & 1 deletion src/gitflow/actions/FinishHotfixAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void actionPerformed(AnActionEvent e) {
}

public void runAction(final Project project, final String hotfixName, final String tagMessage){
super.runAction(project, null, hotfixName);
super.runAction(project, null, hotfixName, null);

final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);

Expand Down
3 changes: 2 additions & 1 deletion src/gitflow/actions/GitflowAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import gitflow.GitflowConfigUtil;
import gitflow.ui.NotifyUtil;

import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;

public class GitflowAction extends DumbAwareAction {
Expand Down Expand Up @@ -70,7 +71,7 @@ public void setup(Project project){
currentBranchName= GitBranchUtil.getBranchNameOrRev(myRepo);
}

public void runAction(Project project, final String baseBranchName, final String branchName){
public void runAction(Project project, final String baseBranchName, final String branchName, @Nullable final Runnable callInAwtLater){
setup(project);
}

Expand Down
18 changes: 11 additions & 7 deletions src/gitflow/actions/StartFeatureAction.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package gitflow.actions;

import com.intellij.dvcs.repo.Repository;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
Expand All @@ -15,6 +13,8 @@
import gitflow.ui.GitflowStartFeatureDialog;
import gitflow.ui.NotifyUtil;

import org.jetbrains.annotations.Nullable;

public class StartFeatureAction extends GitflowAction {

public StartFeatureAction() {
Expand All @@ -36,21 +36,24 @@ public void actionPerformed(AnActionEvent e) {
final String featureName = dialog.getNewBranchName();
final String baseBranchName = dialog.getBaseBranchName();

this.runAction(e.getProject(), baseBranchName, featureName);
this.runAction(e.getProject(), baseBranchName, featureName, null);
}

public void runAction(Project project, final String baseBranchName, final String featureName){
super.runAction(project, baseBranchName, featureName);
public void runAction(Project project, final String baseBranchName, final String featureName, @Nullable final Runnable callInAwtLater){
super.runAction(project, baseBranchName, featureName, callInAwtLater);

new Task.Backgroundable(myProject, "Starting feature " + featureName, false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
createFeatureBranch(baseBranchName, featureName);
final GitCommandResult commandResult = createFeatureBranch(baseBranchName, featureName);
if (callInAwtLater != null && commandResult.success()) {
callInAwtLater.run();
}
}
}.queue();
}

private void createFeatureBranch(String baseBranchName, String featureName) {
private GitCommandResult createFeatureBranch(String baseBranchName, String featureName) {
GitflowErrorsListener errorListener = new GitflowErrorsListener(myProject);
GitCommandResult result = myGitflow.startFeature(myRepo, featureName, baseBranchName, errorListener);

Expand All @@ -63,5 +66,6 @@ private void createFeatureBranch(String baseBranchName, String featureName) {

myRepo.update();
virtualFileMananger.asyncRefresh(null); //update editors
return result;
}
}
17 changes: 12 additions & 5 deletions src/gitflow/actions/StartHotfixAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import gitflow.ui.GitflowStartHotfixDialog;
import gitflow.ui.NotifyUtil;

import org.jetbrains.annotations.Nullable;


public class StartHotfixAction extends GitflowAction {

Expand All @@ -36,21 +38,24 @@ public void actionPerformed(AnActionEvent e) {
final String hotfixName = dialog.getNewBranchName();
final String baseBranchName = dialog.getBaseBranchName();

this.runAction(e.getProject(), baseBranchName, hotfixName);
this.runAction(e.getProject(), baseBranchName, hotfixName, null);
}

public void runAction(Project project, final String baseBranchName, final String hotfixName){
super.runAction(project, baseBranchName, hotfixName);
public void runAction(Project project, final String baseBranchName, final String hotfixName, @Nullable final Runnable callInAwtLater){
super.runAction(project, baseBranchName, hotfixName, callInAwtLater);

new Task.Backgroundable(myProject, "Starting hotfix " + hotfixName, false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
createHotfixBranch(baseBranchName, hotfixName);
final GitCommandResult commandResult = createHotfixBranch(baseBranchName, hotfixName);
if (callInAwtLater != null && commandResult.success()) {
callInAwtLater.run();
}
}
}.queue();
}

private void createHotfixBranch(String baseBranchName, String hotfixBranchName) {
private GitCommandResult createHotfixBranch(String baseBranchName, String hotfixBranchName) {
GitflowErrorsListener errorListener = new GitflowErrorsListener(myProject);
GitCommandResult result = myGitflow.startHotfix(myRepo, hotfixBranchName, baseBranchName, errorListener);

Expand All @@ -63,5 +68,7 @@ private void createHotfixBranch(String baseBranchName, String hotfixBranchName)
}

myRepo.update();

return result;
}
}
22 changes: 11 additions & 11 deletions src/gitflow/ui/GitflowCloseTaskPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vcs.VcsTaskHandler;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskManager;
Expand All @@ -12,8 +11,6 @@
import gitflow.*;
import gitflow.actions.FinishFeatureAction;
import gitflow.actions.FinishHotfixAction;
import gitflow.actions.GitflowAction;
import gitflow.actions.StartFeatureAction;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
Expand Down Expand Up @@ -98,15 +95,18 @@ public JComponent getPanel() {
@Override
public void commit() {
String taskFullBranchName = gitflowState.getTaskBranch(myTask);
String taskBranchName = gitflowBranchUtil.stripFullBranchName(taskFullBranchName);

if (finishFeatureCheckbox.isSelected()){
FinishFeatureAction action = new FinishFeatureAction(myRepo);
action.runAction(myProject, taskBranchName);
}
else if (finishHotfixCheckbox.isSelected()){
FinishHotfixAction action = new FinishHotfixAction(myRepo);
action.runAction(myProject, taskBranchName, tagMessageTextField.getText());
// test if current task is a gitflow task
if (taskFullBranchName != null) {
String taskBranchName = gitflowBranchUtil.stripFullBranchName(taskFullBranchName);

if (finishFeatureCheckbox.isSelected()) {
FinishFeatureAction action = new FinishFeatureAction(myRepo);
action.runAction(myProject, taskBranchName);
} else if (finishHotfixCheckbox.isSelected()) {
FinishHotfixAction action = new FinishHotfixAction(myRepo);
action.runAction(myProject, taskBranchName, tagMessageTextField.getText());
}
}
}
}
41 changes: 33 additions & 8 deletions src/gitflow/ui/GitflowOpenTaskPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsTaskHandler;
import com.intellij.tasks.LocalTask;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskManager;
import com.intellij.tasks.impl.TaskManagerImpl;
Expand All @@ -21,6 +22,9 @@
import javax.swing.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Collections;

import static com.intellij.openapi.vcs.VcsTaskHandler.*;

public class GitflowOpenTaskPanel extends TaskDialogPanel implements ItemListener {
private JRadioButton noActionRadioButton;
Expand All @@ -37,6 +41,7 @@ public class GitflowOpenTaskPanel extends TaskDialogPanel implements ItemListene
private GitflowBranchUtil gitflowBranchUtil;
private TaskManagerImpl myTaskManager;
private VcsTaskHandler myVcsTaskHandler;
private LocalTask myPreviousTask;
private Task currentTask;

private GitflowState gitflowState;
Expand All @@ -48,6 +53,7 @@ public GitflowOpenTaskPanel(Project project, Task task, GitRepository repo){
myRepo = repo;

myTaskManager = (TaskManagerImpl) TaskManager.getManager(project);
myPreviousTask = myTaskManager.getActiveTask();
VcsTaskHandler[] vcsTaskHAndlers = VcsTaskHandler.getAllHandlers(project);
if (vcsTaskHAndlers.length > 0){
//todo handle case of multiple vcs handlers
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a211795

Please sign in to comment.