From 58dd82b4ebc7cfabdf675b5c3d380a8e930ede42 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 4 Apr 2014 20:24:39 +0300 Subject: [PATCH 1/5] bump for next version --- META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 8702bec..5f0239e 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -2,7 +2,7 @@ Git Flow Integration Gitflow Git Flow Integration - 0.3.5 + 0.3.6 VCS Integration Opher Vishnia From 9e1f1eecfb00acf1c76b660bf1295cfda55e58ed Mon Sep 17 00:00:00 2001 From: OpherV Date: Mon, 7 Apr 2014 10:23:52 +0300 Subject: [PATCH 2/5] support for 136 --- META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 5f0239e..dad2310 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -9,7 +9,7 @@ com.intellij.modules.vcs Git4Idea - + From 980cc1a1617f4a86c511bc3842d7ddc30fa318a2 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Thu, 10 Apr 2014 22:10:21 +0300 Subject: [PATCH 3/5] typo fix for new notifyutil, fix for #34 (errors on gitflow init) --- src/gitflow/actions/InitRepoAction.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gitflow/actions/InitRepoAction.java b/src/gitflow/actions/InitRepoAction.java index 76a61bd..4af0c7e 100644 --- a/src/gitflow/actions/InitRepoAction.java +++ b/src/gitflow/actions/InitRepoAction.java @@ -5,6 +5,7 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.util.Key; import git4idea.commands.GitCommandResult; +import git4idea.repo.GitRepository; import gitflow.GitflowInitOptions; import gitflow.ui.GitflowInitOptionsDialog; import gitflow.ui.NotifyUtil; @@ -35,11 +36,13 @@ public void run(@NotNull ProgressIndicator indicator) { if (result.success()) { String publishedFeatureMessage = String.format("Initialized gitflow repo"); - NotifyUtil.notifySuccess(myProject, publishedFeatureMessage, ""); + NotifyUtil.notifySuccess(myProject, "", publishedFeatureMessage); } else { NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } + //update the widget + myProject.getMessageBus().syncPublisher(GitRepository.GIT_REPO_CHANGE).repositoryChanged(repo); repo.update(); } }.queue(); From f7bf5e90ef0cdcef49e81bd51843cf433e8f8a44 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Thu, 10 Apr 2014 23:33:43 +0300 Subject: [PATCH 4/5] added information notification to notifyutil in addition to error and success --- src/gitflow/ui/NotifyUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gitflow/ui/NotifyUtil.java b/src/gitflow/ui/NotifyUtil.java index 81798fa..e78f623 100644 --- a/src/gitflow/ui/NotifyUtil.java +++ b/src/gitflow/ui/NotifyUtil.java @@ -19,6 +19,10 @@ public static void notifySuccess(Project project, String title, String message) notify(NotificationType.INFORMATION, BALLOON_NOTIFICATION, project, title, message); } + public static void notifyInfo(Project project, String title, String message) { + notify(NotificationType.INFORMATION, TOOLWINDOW_NOTIFICATION, project, title, message); + } + public static void notifyError(Project project, String title, String message) { notify(NotificationType.ERROR, TOOLWINDOW_NOTIFICATION, project, title, message); } From ca9df4b363247455886e322300b23bfa2acdfa9e Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 11 Apr 2014 00:09:35 +0300 Subject: [PATCH 5/5] sorted out #16. Finish release now invokes the merge dialog as well --- src/gitflow/actions/FinishFeatureAction.java | 43 ++++--------------- src/gitflow/actions/FinishReleaseAction.java | 35 +++++++++++++-- src/gitflow/actions/GitflowAction.java | 45 ++++++++++++++++++++ 3 files changed, 84 insertions(+), 39 deletions(-) diff --git a/src/gitflow/actions/FinishFeatureAction.java b/src/gitflow/actions/FinishFeatureAction.java index 2ec537a..67fab28 100644 --- a/src/gitflow/actions/FinishFeatureAction.java +++ b/src/gitflow/actions/FinishFeatureAction.java @@ -54,7 +54,7 @@ public void run(@NotNull ProgressIndicator indicator) { NotifyUtil.notifySuccess(myProject, featureName, finishedFeatureMessage); } else if(errorLineHandler.hasMergeError){ - + // (merge errors are handled in the onSuccess handler) } else { NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); @@ -66,42 +66,15 @@ else if(errorLineHandler.hasMergeError){ public void onSuccess() { super.onSuccess(); + //merge conflicts if necessary + if (errorLineHandler.hasMergeError){ + if (handleMerge()){ + FinishFeatureAction completeFinishFeatureAction = new FinishFeatureAction(featureName); + completeFinishFeatureAction.actionPerformed(event); + } - //ugly, but required for intellij to catch up with the external changes made by - //the CLI before being able to run the merge tool - virtualFileMananger.syncRefresh(); - try { - Thread.sleep(500); - } - catch (InterruptedException ignored) { - } - - - //TODO: refactor this logic to work in case of finishRelease as well - if (errorLineHandler.hasMergeError){ - GitflowActions.runMergeTool(); - repo.update(); - - //if merge was completed successfully, finish the action - //note that if it wasn't intellij is left in the "merging state", and git4idea provides no UI way to resolve it - int answer = Messages.showYesNoDialog(myProject, "Was the merge completed succesfully?", "Merge", Messages.getQuestionIcon()); - if (answer==0){ - GitMerger gitMerger=new GitMerger(myProject); + } - try { - gitMerger.mergeCommit(gitMerger.getMergingRoots()); - } catch (VcsException e1) { - NotifyUtil.notifyError(myProject, "Error", "Error committing merge result"); - e1.printStackTrace(); - } - - FinishFeatureAction completeFinishFeatureAction = new FinishFeatureAction(featureName); - completeFinishFeatureAction.actionPerformed(event); - - } - - - } } }.queue(); } diff --git a/src/gitflow/actions/FinishReleaseAction.java b/src/gitflow/actions/FinishReleaseAction.java index 50f84b6..980f793 100644 --- a/src/gitflow/actions/FinishReleaseAction.java +++ b/src/gitflow/actions/FinishReleaseAction.java @@ -13,10 +13,19 @@ public class FinishReleaseAction extends GitflowAction { + String customReleaseName=null; + String customtagMessage=null; + FinishReleaseAction() { super("Finish Release"); } + FinishReleaseAction(String name, String tagMessage) { + super("Finish Release"); + customReleaseName=name; + customtagMessage=tagMessage; + } + @Override public void actionPerformed(AnActionEvent e) { super.actionPerformed(e); @@ -24,19 +33,29 @@ public void actionPerformed(AnActionEvent e) { String currentBranchName = GitBranchUtil.getBranchNameOrRev(repo); if (currentBranchName.isEmpty()==false){ - final String releaseName = GitflowConfigUtil.getReleaseNameFromBranch(myProject, currentBranchName); + final AnActionEvent event=e; + + final String tagMessage; + final String releaseName; + + // Check if a release name was specified, otherwise take name from current branch + releaseName = customReleaseName!=null ? customReleaseName:GitflowConfigUtil.getReleaseNameFromBranch(myProject, currentBranchName); + final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject); String defaultTagMessage= GitflowConfigurable.getCustomTagCommitMessage(myProject); defaultTagMessage=defaultTagMessage.replace("%name%", releaseName); String tagMessageDraft; - final String tagMessage; boolean cancelAction=false; if (GitflowConfigurable.dontTagRelease(myProject)) { tagMessage=""; } + else if (customtagMessage!=null){ + //probably repeating the release finish after a merge + tagMessage=customtagMessage; + } else{ tagMessageDraft= Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Release", Messages.getQuestionIcon(), defaultTagMessage, null); if (tagMessageDraft==null){ @@ -61,6 +80,9 @@ public void run(@NotNull ProgressIndicator indicator) { String finishedReleaseMessage = String.format("The release branch '%s%s' was merged into '%s' and '%s'", featurePrefix, releaseName, developBranch, masterBranch); NotifyUtil.notifySuccess(myProject, releaseName, finishedReleaseMessage); } + else if(errorLineHandler.hasMergeError){ + // (merge errors are handled in the onSuccess handler) + } else { NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } @@ -73,8 +95,13 @@ public void run(@NotNull ProgressIndicator indicator) { public void onSuccess() { super.onSuccess(); - virtualFileMananger.syncRefresh(); - repo.update(); + //merge conflicts if necessary + if (errorLineHandler.hasMergeError){ + if (handleMerge()) { + FinishReleaseAction completeFinisReleaseAction = new FinishReleaseAction(releaseName,tagMessage); + completeFinisReleaseAction.actionPerformed(event); + } + } } }.queue(); diff --git a/src/gitflow/actions/GitflowAction.java b/src/gitflow/actions/GitflowAction.java index 56580fe..c4f62f2 100644 --- a/src/gitflow/actions/GitflowAction.java +++ b/src/gitflow/actions/GitflowAction.java @@ -4,12 +4,16 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFileManager; import git4idea.branch.GitBranchUtil; +import git4idea.merge.GitMerger; import git4idea.repo.GitRepository; import gitflow.Gitflow; import gitflow.GitflowBranchUtil; import gitflow.GitflowConfigUtil; +import gitflow.ui.NotifyUtil; import java.util.ArrayList; @@ -53,4 +57,45 @@ public void actionPerformed(AnActionEvent e) { masterBranch= GitflowConfigUtil.getMasterBranch(myProject); developBranch= GitflowConfigUtil.getDevelopBranch(myProject); } + + //returns true if merge successful, false otherwise + public boolean handleMerge(){ + //ugly, but required for intellij to catch up with the external changes made by + //the CLI before being able to run the merge tool + virtualFileMananger.syncRefresh(); + try { + Thread.sleep(500); + } + catch (InterruptedException ignored) { + } + + + GitflowActions.runMergeTool(); + repo.update(); + + //if merge was completed successfully, finish the action + //note that if it wasn't intellij is left in the "merging state", and git4idea provides no UI way to resolve it + //merging can be done via intellij itself or any other util + int answer = Messages.showYesNoDialog(myProject, "Was the merge completed succesfully?", "Merge", Messages.getQuestionIcon()); + if (answer==0){ + GitMerger gitMerger=new GitMerger(myProject); + + try { + gitMerger.mergeCommit(gitMerger.getMergingRoots()); + } catch (VcsException e1) { + NotifyUtil.notifyError(myProject, "Error", "Error committing merge result"); + e1.printStackTrace(); + } + + return true; + } + else{ + + NotifyUtil.notifyInfo(myProject,"Merge incomplete","To manually complete the merge choose VCS > Git > Resolve Conflicts.\n" + + "Once done, commit the merged files.\n"); + return false; + } + + + } }