From 0eb61b5fe95749499536332563478c12e8358e7a Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 30 Dec 2018 00:00:45 +0100 Subject: [PATCH 01/14] Improve timings by caching branches --- src/main/java/gitflow/GitflowBranchUtil.java | 60 +++++++++++--------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/src/main/java/gitflow/GitflowBranchUtil.java b/src/main/java/gitflow/GitflowBranchUtil.java index e9a92c5..7366a7f 100644 --- a/src/main/java/gitflow/GitflowBranchUtil.java +++ b/src/main/java/gitflow/GitflowBranchUtil.java @@ -29,6 +29,10 @@ public class GitflowBranchUtil { String prefixRelease; String prefixHotfix; String prefixBugfix; + private ArrayList remoteBranches; + private ArrayList remoteBranchNames; + private ArrayList localBranches; + private ArrayList localBranchNames; public GitflowBranchUtil(Project project, GitRepository repo){ myProject=project; @@ -42,6 +46,9 @@ public GitflowBranchUtil(Project project, GitRepository repo){ prefixRelease = GitflowConfigUtil.getReleasePrefix(project, repo); prefixHotfix = GitflowConfigUtil.getHotfixPrefix(project, repo); prefixBugfix = GitflowConfigUtil.getBugfixPrefix(project, repo); + + initRemoteBranches(); + initLocalBranchNames(); } } @@ -97,9 +104,31 @@ public boolean isBranchBugfix(String branchName){ return branchName.startsWith(prefixBugfix); } + private void initRemoteBranches() { + remoteBranches = + new ArrayList(myRepo.getBranches().getRemoteBranches()); + remoteBranchNames = new ArrayList(); + + for(Iterator i = remoteBranches.iterator(); i.hasNext(); ) { + GitRemoteBranch branch = i.next(); + remoteBranchNames.add(branch.getName()); + } + } + + private void initLocalBranchNames(){ + localBranches = + new ArrayList(myRepo.getBranches().getLocalBranches()); + localBranchNames = new ArrayList(); + + for(Iterator i = localBranches.iterator(); i.hasNext(); ) { + GitLocalBranch branch = i.next(); + localBranchNames.add(branch.getName()); + } + } + //if no prefix specified, returns all remote branches public ArrayList getRemoteBranchesWithPrefix(String prefix){ - ArrayList remoteBranches = getRemoteBranchNames(); + ArrayList remoteBranches = remoteBranchNames; ArrayList selectedBranches = new ArrayList(); for(Iterator i = remoteBranches.iterator(); i.hasNext(); ) { @@ -127,40 +156,19 @@ public ArrayList filterBranchListByPrefix(Collection inputBranch } public ArrayList getRemoteBranchNames(){ - ArrayList remoteBranches = new ArrayList(myRepo.getBranches().getRemoteBranches()); - ArrayList branchNameList = new ArrayList(); - - for(Iterator i = remoteBranches.iterator(); i.hasNext(); ) { - GitRemoteBranch branch = i.next(); - branchNameList.add(branch.getName()); - } - - return branchNameList; + return remoteBranchNames; } - - public ArrayList getLocalBranchNames(){ - ArrayList localBranches = new ArrayList(myRepo.getBranches().getLocalBranches()); - ArrayList branchNameList = new ArrayList(); - - for(Iterator i = localBranches.iterator(); i.hasNext(); ) { - GitLocalBranch branch = i.next(); - branchNameList.add(branch.getName()); - } - - return branchNameList; + public ArrayList getLocalBranchNames() { + return localBranchNames; } - - public GitRemote getRemoteByBranch(String branchName){ GitRemote remote=null; - ArrayList remoteBranches= new ArrayList(myRepo.getBranches().getRemoteBranches()); - for(Iterator i = remoteBranches.iterator(); i.hasNext(); ) { GitRemoteBranch branch = i.next(); - if (branch.getName()==branchName){ + if (branch.getName().equals(branchName)){ remote=branch.getRemote(); break; } From 420029e6d554bc53f2164a9ac54f0b6ca88fcf61 Mon Sep 17 00:00:00 2001 From: ben Date: Sun, 30 Dec 2018 00:06:14 +0100 Subject: [PATCH 02/14] Less use of GitflowConfigUtil saves time --- src/main/java/gitflow/GitflowBranchUtil.java | 34 +++++++++++--------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/gitflow/GitflowBranchUtil.java b/src/main/java/gitflow/GitflowBranchUtil.java index 7366a7f..d468ccc 100644 --- a/src/main/java/gitflow/GitflowBranchUtil.java +++ b/src/main/java/gitflow/GitflowBranchUtil.java @@ -23,12 +23,13 @@ public class GitflowBranchUtil { Project myProject; GitRepository myRepo; - String currentBranchName; - String branchnameMaster; - String prefixFeature; - String prefixRelease; - String prefixHotfix; - String prefixBugfix; + private String currentBranchName; + private String branchnameMaster; + private String branchnameDevelop; + private String prefixFeature; + private String prefixRelease; + private String prefixHotfix; + private String prefixBugfix; private ArrayList remoteBranches; private ArrayList remoteBranchNames; private ArrayList localBranches; @@ -42,6 +43,7 @@ public GitflowBranchUtil(Project project, GitRepository repo){ currentBranchName = GitBranchUtil.getBranchNameOrRev(repo); branchnameMaster= GitflowConfigUtil.getMasterBranch(project, repo); + branchnameDevelop = GitflowConfigUtil.getDevelopBranch(project, repo); prefixFeature = GitflowConfigUtil.getFeaturePrefix(project, repo); prefixRelease = GitflowConfigUtil.getReleasePrefix(project, repo); prefixHotfix = GitflowConfigUtil.getHotfixPrefix(project, repo); @@ -52,16 +54,18 @@ public GitflowBranchUtil(Project project, GitRepository repo){ } } + public String getCurrentBranchName() { + return currentBranchName; + } + public boolean hasGitflow(){ - boolean hasGitflow=false; - - hasGitflow = myRepo != null - && GitflowConfigUtil.getMasterBranch(myProject, myRepo)!=null - && GitflowConfigUtil.getDevelopBranch(myProject, myRepo)!=null - && GitflowConfigUtil.getFeaturePrefix(myProject, myRepo)!=null - && GitflowConfigUtil.getReleasePrefix(myProject, myRepo)!=null - && GitflowConfigUtil.getHotfixPrefix(myProject, myRepo)!=null - && GitflowConfigUtil.getBugfixPrefix(myProject, myRepo)!=null; + boolean hasGitflow = myRepo != null + && branchnameMaster != null + && branchnameDevelop != null + && prefixFeature != null + && prefixRelease != null + && prefixHotfix != null + && prefixBugfix != null; return hasGitflow; } From 5e45e84faf718d4d15045732a4cb74b1ceb50052 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 3 Jan 2019 21:17:40 +0100 Subject: [PATCH 03/14] Restructure, let the actions figure out if they're needed --- src/main/java/gitflow/GitflowBranchUtil.java | 24 +++ .../gitflow/actions/AbstractBranchAction.java | 60 +++++++ .../actions/AbstractPublishAction.java | 22 +++ .../gitflow/actions/AbstractStartAction.java | 30 ++++ .../gitflow/actions/AbstractTrackAction.java | 36 +++++ .../gitflow/actions/FinishBugfixAction.java | 8 +- .../gitflow/actions/FinishFeatureAction.java | 8 +- .../gitflow/actions/FinishHotfixAction.java | 6 +- .../gitflow/actions/FinishReleaseAction.java | 8 +- .../java/gitflow/actions/GitflowAction.java | 26 +-- .../java/gitflow/actions/InitRepoAction.java | 14 ++ .../gitflow/actions/PublishBugfixAction.java | 10 +- .../gitflow/actions/PublishFeatureAction.java | 10 +- .../gitflow/actions/PublishHotfixAction.java | 6 +- .../gitflow/actions/PublishReleaseAction.java | 6 +- .../java/gitflow/actions/RepoActions.java | 150 ++++-------------- .../gitflow/actions/StartBugfixAction.java | 2 +- .../gitflow/actions/StartFeatureAction.java | 9 +- .../gitflow/actions/StartHotfixAction.java | 9 +- .../gitflow/actions/StartReleaseAction.java | 2 +- .../gitflow/actions/TrackBugfixAction.java | 6 +- .../gitflow/actions/TrackFeatureAction.java | 6 +- .../gitflow/actions/TrackReleaseAction.java | 6 +- 23 files changed, 288 insertions(+), 176 deletions(-) create mode 100644 src/main/java/gitflow/actions/AbstractBranchAction.java create mode 100644 src/main/java/gitflow/actions/AbstractPublishAction.java create mode 100644 src/main/java/gitflow/actions/AbstractStartAction.java create mode 100644 src/main/java/gitflow/actions/AbstractTrackAction.java diff --git a/src/main/java/gitflow/GitflowBranchUtil.java b/src/main/java/gitflow/GitflowBranchUtil.java index d468ccc..66b38c9 100644 --- a/src/main/java/gitflow/GitflowBranchUtil.java +++ b/src/main/java/gitflow/GitflowBranchUtil.java @@ -70,6 +70,30 @@ public boolean hasGitflow(){ return hasGitflow; } + public String getBranchnameMaster() { + return branchnameMaster; + } + + public String getBranchnameDevelop() { + return branchnameDevelop; + } + + public String getPrefixFeature() { + return prefixFeature; + } + + public String getPrefixRelease() { + return prefixRelease; + } + + public String getPrefixHotfix() { + return prefixHotfix; + } + + public String getPrefixBugfix() { + return prefixBugfix; + } + public boolean isCurrentBranchMaster(){ return currentBranchName.startsWith(branchnameMaster); } diff --git a/src/main/java/gitflow/actions/AbstractBranchAction.java b/src/main/java/gitflow/actions/AbstractBranchAction.java new file mode 100644 index 0000000..7016335 --- /dev/null +++ b/src/main/java/gitflow/actions/AbstractBranchAction.java @@ -0,0 +1,60 @@ +package gitflow.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import git4idea.repo.GitRepository; +import org.jetbrains.annotations.NotNull; + +public abstract class AbstractBranchAction extends GitflowAction { + enum BranchType { + Feature, Release, Bugfix, Hotfix + } + + BranchType type; + + AbstractBranchAction(String actionName, BranchType type) { + super(actionName); + this.type = type; + } + + AbstractBranchAction(GitRepository repo, String actionName, BranchType type) { + super(repo, actionName); + this.type = type; + } + + + @Override + public void update(@NotNull AnActionEvent e) { + if (branchUtil == null) { + e.getPresentation().setEnabledAndVisible(false); + return; + } + + //Disable and hide when gitflow has not been setup + if (branchUtil.hasGitflow() == false) { + e.getPresentation().setEnabledAndVisible(false); + return; + } + + //Disable and hide when the branch-type is incorrect + if (isActionAllowedForBranch() == false) { + e.getPresentation().setEnabledAndVisible(false); + } else { + e.getPresentation().setEnabledAndVisible(true); + } + } + + protected boolean isActionAllowedForBranch() { + switch (type) { + case Feature: + return branchUtil.isCurrentBranchFeature(); + case Release: + return branchUtil.isCurrentBranchRelease(); + case Bugfix: + return branchUtil.isCurrentBranchBugfix(); + case Hotfix: + return branchUtil.isCurrentBranchHotfix(); + default: + return false; + } + } +} diff --git a/src/main/java/gitflow/actions/AbstractPublishAction.java b/src/main/java/gitflow/actions/AbstractPublishAction.java new file mode 100644 index 0000000..bc0d4d8 --- /dev/null +++ b/src/main/java/gitflow/actions/AbstractPublishAction.java @@ -0,0 +1,22 @@ +package gitflow.actions; + +import git4idea.repo.GitRepository; + +public abstract class AbstractPublishAction extends AbstractBranchAction { + AbstractPublishAction(String actionName, BranchType type) { + super(actionName, type); + } + + AbstractPublishAction(GitRepository repo, String actionName, BranchType type) { + super(repo, actionName, type); + } + + @Override + protected boolean isActionAllowedForBranch() { + if (!super.isActionAllowedForBranch()) { + return false; + } + + return !branchUtil.isCurrentBranchPublished(); + } +} diff --git a/src/main/java/gitflow/actions/AbstractStartAction.java b/src/main/java/gitflow/actions/AbstractStartAction.java new file mode 100644 index 0000000..aa6efa1 --- /dev/null +++ b/src/main/java/gitflow/actions/AbstractStartAction.java @@ -0,0 +1,30 @@ +package gitflow.actions; + +import com.intellij.openapi.actionSystem.AnActionEvent; +import git4idea.repo.GitRepository; +import gitflow.GitflowBranchUtil; +import gitflow.GitflowBranchUtilManager; +import org.jetbrains.annotations.NotNull; + +public abstract class AbstractStartAction extends GitflowAction { + AbstractStartAction(String actionName) { + super(actionName); + } + + AbstractStartAction(GitRepository repo, String actionName) { + super(repo, actionName); + } + + + @Override + public void update(@NotNull AnActionEvent e) { + GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); + + //Disable and hide when gitflow has not been setup + if (branchUtil.hasGitflow() == false) { + e.getPresentation().setEnabledAndVisible(false); + } else { + e.getPresentation().setEnabledAndVisible(true); + } + } +} diff --git a/src/main/java/gitflow/actions/AbstractTrackAction.java b/src/main/java/gitflow/actions/AbstractTrackAction.java new file mode 100644 index 0000000..7e3f06d --- /dev/null +++ b/src/main/java/gitflow/actions/AbstractTrackAction.java @@ -0,0 +1,36 @@ +package gitflow.actions; + +import git4idea.repo.GitRepository; + +public abstract class AbstractTrackAction extends AbstractBranchAction { + AbstractTrackAction(String actionName, BranchType type) { + super(actionName, type); + } + + AbstractTrackAction(GitRepository repo, String actionName, BranchType type) { + super(repo, actionName, type); + } + + @Override + protected boolean isActionAllowedForBranch() { + String prefix; + switch (type) { + case Feature: + prefix = featurePrefix; + break; + case Release: + prefix = releasePrefix; + break; + case Bugfix: + prefix = bugfixPrefix; + break; + default: + return false; + } + + boolean noRemoteBranches = branchUtil.getRemoteBranchesWithPrefix(prefix).isEmpty(); + boolean trackedAllBranches = branchUtil.areAllBranchesTracked(prefix); + + return noRemoteBranches == false && trackedAllBranches == false; + } +} diff --git a/src/main/java/gitflow/actions/FinishBugfixAction.java b/src/main/java/gitflow/actions/FinishBugfixAction.java index fa1d1fa..a94809c 100644 --- a/src/main/java/gitflow/actions/FinishBugfixAction.java +++ b/src/main/java/gitflow/actions/FinishBugfixAction.java @@ -11,20 +11,20 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class FinishBugfixAction extends GitflowAction { +public class FinishBugfixAction extends AbstractBranchAction { String customBugfixName =null; public FinishBugfixAction() { - super("Finish Bugfix"); + super("Finish Bugfix", BranchType.Bugfix); } public FinishBugfixAction(GitRepository repo) { - super(repo, "Finish Bugfix"); + super(repo, "Finish Bugfix", BranchType.Bugfix); } FinishBugfixAction(GitRepository repo, String name) { - super(repo, "Finish Bugfix"); + super(repo, "Finish Bugfix", BranchType.Bugfix); customBugfixName =name; } diff --git a/src/main/java/gitflow/actions/FinishFeatureAction.java b/src/main/java/gitflow/actions/FinishFeatureAction.java index 0f3fce4..14c2d3d 100644 --- a/src/main/java/gitflow/actions/FinishFeatureAction.java +++ b/src/main/java/gitflow/actions/FinishFeatureAction.java @@ -11,20 +11,20 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class FinishFeatureAction extends GitflowAction { +public class FinishFeatureAction extends AbstractBranchAction { String customFeatureName=null; public FinishFeatureAction() { - super("Finish Feature"); + super("Finish Feature", BranchType.Feature); } public FinishFeatureAction(GitRepository repo) { - super(repo, "Finish Feature"); + super(repo, "Finish Feature", BranchType.Feature); } FinishFeatureAction(GitRepository repo, String name) { - super(repo, "Finish Feature"); + super(repo, "Finish Feature", BranchType.Feature); customFeatureName=name; } diff --git a/src/main/java/gitflow/actions/FinishHotfixAction.java b/src/main/java/gitflow/actions/FinishHotfixAction.java index b6a05a2..efabc49 100644 --- a/src/main/java/gitflow/actions/FinishHotfixAction.java +++ b/src/main/java/gitflow/actions/FinishHotfixAction.java @@ -13,13 +13,13 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class FinishHotfixAction extends GitflowAction { +public class FinishHotfixAction extends AbstractBranchAction { public FinishHotfixAction() { - super("Finish Hotfix"); + super("Finish Hotfix", BranchType.Hotfix); } public FinishHotfixAction(GitRepository repo) { - super(repo, "Finish Hotfix"); + super(repo, "Finish Hotfix", BranchType.Hotfix); } @Override diff --git a/src/main/java/gitflow/actions/FinishReleaseAction.java b/src/main/java/gitflow/actions/FinishReleaseAction.java index 7166b88..1848d1a 100644 --- a/src/main/java/gitflow/actions/FinishReleaseAction.java +++ b/src/main/java/gitflow/actions/FinishReleaseAction.java @@ -12,21 +12,21 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class FinishReleaseAction extends GitflowAction { +public class FinishReleaseAction extends AbstractBranchAction { String customReleaseName=null; String customtagMessage=null; FinishReleaseAction() { - super("Finish Release"); + super("Finish Release", AbstractBranchAction.BranchType.Release); } FinishReleaseAction(GitRepository repo) { - super(repo, "Finish Release"); + super(repo, "Finish Release", BranchType.Release); } FinishReleaseAction(String name, String tagMessage) { - super("Finish Release"); + super("Finish Release", BranchType.Release); customReleaseName = name; customtagMessage = tagMessage; } diff --git a/src/main/java/gitflow/actions/GitflowAction.java b/src/main/java/gitflow/actions/GitflowAction.java index fb9815e..182259d 100644 --- a/src/main/java/gitflow/actions/GitflowAction.java +++ b/src/main/java/gitflow/actions/GitflowAction.java @@ -13,7 +13,6 @@ import gitflow.Gitflow; import gitflow.GitflowBranchUtil; import gitflow.GitflowBranchUtilManager; -import gitflow.GitflowConfigUtil; import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.Nullable; @@ -43,6 +42,9 @@ public class GitflowAction extends DumbAwareAction { GitflowAction(GitRepository repo, String actionName){ super(actionName); myRepo = repo; + + branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); + setupPrefixes(); } @Override @@ -56,21 +58,25 @@ public void actionPerformed(AnActionEvent e) { setup(project); } - public void setup(Project project){ + private void setup(Project project){ myProject = project; virtualFileMananger = VirtualFileManager.getInstance(); repos.add(myRepo); - featurePrefix = GitflowConfigUtil.getFeaturePrefix(myProject, myRepo); - releasePrefix = GitflowConfigUtil.getReleasePrefix(myProject, myRepo); - hotfixPrefix= GitflowConfigUtil.getHotfixPrefix(myProject, myRepo); - bugfixPrefix = GitflowConfigUtil.getBugfixPrefix(myProject, myRepo); - masterBranch= GitflowConfigUtil.getMasterBranch(myProject, myRepo); - developBranch= GitflowConfigUtil.getDevelopBranch(myProject, myRepo); - branchUtil= GitflowBranchUtilManager.getBranchUtil(myRepo); - currentBranchName= GitBranchUtil.getBranchNameOrRev(myRepo); + setupPrefixes(); + } + + private void setupPrefixes() { + featurePrefix = branchUtil.getPrefixFeature(); + releasePrefix = branchUtil.getPrefixRelease(); + hotfixPrefix = branchUtil.getPrefixHotfix(); + bugfixPrefix = branchUtil.getPrefixBugfix(); + masterBranch = branchUtil.getBranchnameMaster(); + developBranch = branchUtil.getBranchnameDevelop(); + + currentBranchName = branchUtil.getCurrentBranchName(); } public void runAction(Project project, final String baseBranchName, final String branchName, @Nullable final Runnable callInAwtLater){ diff --git a/src/main/java/gitflow/actions/InitRepoAction.java b/src/main/java/gitflow/actions/InitRepoAction.java index 31ef257..b8ca252 100644 --- a/src/main/java/gitflow/actions/InitRepoAction.java +++ b/src/main/java/gitflow/actions/InitRepoAction.java @@ -6,6 +6,8 @@ import com.intellij.openapi.util.Key; import git4idea.commands.GitCommandResult; import git4idea.repo.GitRepository; +import gitflow.GitflowBranchUtil; +import gitflow.GitflowBranchUtilManager; import gitflow.GitflowInitOptions; import gitflow.ui.GitflowInitOptionsDialog; import gitflow.ui.NotifyUtil; @@ -21,6 +23,18 @@ public class InitRepoAction extends GitflowAction { super(repo,"Init Repo"); } + @Override + public void update(@NotNull AnActionEvent e) { + GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); + + //Disable and hide when gitflow has not been setup + if (branchUtil.hasGitflow()) { + e.getPresentation().setEnabledAndVisible(false); + } else { + e.getPresentation().setEnabledAndVisible(true); + } + } + @Override public void actionPerformed(AnActionEvent e) { super.actionPerformed(e); diff --git a/src/main/java/gitflow/actions/PublishBugfixAction.java b/src/main/java/gitflow/actions/PublishBugfixAction.java index 91ea10d..243fe9c 100644 --- a/src/main/java/gitflow/actions/PublishBugfixAction.java +++ b/src/main/java/gitflow/actions/PublishBugfixAction.java @@ -9,11 +9,15 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class PublishBugfixAction extends GitflowAction { +public class PublishBugfixAction extends AbstractPublishAction { - PublishBugfixAction(){ super("Publish Bugfix");} + PublishBugfixAction(){ + super("Publish Bugfix", BranchType.Bugfix); + } - PublishBugfixAction(GitRepository repo){ super(repo,"Publish Bugfix");} + PublishBugfixAction(GitRepository repo){ + super(repo, "Publish Bugfix", BranchType.Bugfix); + } @Override public void actionPerformed(AnActionEvent anActionEvent) { diff --git a/src/main/java/gitflow/actions/PublishFeatureAction.java b/src/main/java/gitflow/actions/PublishFeatureAction.java index 4369eb1..f76a977 100644 --- a/src/main/java/gitflow/actions/PublishFeatureAction.java +++ b/src/main/java/gitflow/actions/PublishFeatureAction.java @@ -9,10 +9,14 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class PublishFeatureAction extends GitflowAction { - PublishFeatureAction(){ super("Publish Feature");} +public class PublishFeatureAction extends AbstractPublishAction { + PublishFeatureAction(){ + super("Publish Feature", BranchType.Feature); + } - PublishFeatureAction(GitRepository repo){ super(repo,"Publish Feature");} + PublishFeatureAction(GitRepository repo){ + super(repo, "Publish Feature", BranchType.Feature); + } @Override public void actionPerformed(AnActionEvent anActionEvent) { diff --git a/src/main/java/gitflow/actions/PublishHotfixAction.java b/src/main/java/gitflow/actions/PublishHotfixAction.java index 8f50876..d084058 100644 --- a/src/main/java/gitflow/actions/PublishHotfixAction.java +++ b/src/main/java/gitflow/actions/PublishHotfixAction.java @@ -10,13 +10,13 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class PublishHotfixAction extends GitflowAction { +public class PublishHotfixAction extends AbstractPublishAction { PublishHotfixAction() { - super("Publish Hotfix"); + super("Publish Hotfix", BranchType.Hotfix); } PublishHotfixAction(GitRepository repo) { - super(repo, "Publish Hotfix"); + super(repo, "Publish Hotfix", BranchType.Hotfix); } @Override diff --git a/src/main/java/gitflow/actions/PublishReleaseAction.java b/src/main/java/gitflow/actions/PublishReleaseAction.java index 44d208f..861ef79 100644 --- a/src/main/java/gitflow/actions/PublishReleaseAction.java +++ b/src/main/java/gitflow/actions/PublishReleaseAction.java @@ -9,14 +9,14 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class PublishReleaseAction extends GitflowAction { +public class PublishReleaseAction extends AbstractPublishAction { PublishReleaseAction(){ - super("Publish Release"); + super("Publish Release", BranchType.Release); } PublishReleaseAction(GitRepository repo){ - super(repo,"Publish Release"); + super(repo,"Publish Release", BranchType.Release); } @Override diff --git a/src/main/java/gitflow/actions/RepoActions.java b/src/main/java/gitflow/actions/RepoActions.java index 6bbf9f1..e5fbed9 100644 --- a/src/main/java/gitflow/actions/RepoActions.java +++ b/src/main/java/gitflow/actions/RepoActions.java @@ -11,9 +11,6 @@ import com.intellij.openapi.project.Project; import git4idea.branch.GitBranchUtil; import git4idea.repo.GitRepository; -import gitflow.GitflowBranchUtil; -import gitflow.GitflowBranchUtilManager; -import gitflow.GitflowConfigUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -23,6 +20,7 @@ class RepoActions extends BranchActionGroup implements PopupElementWithAdditionalInfo, FileEditorManagerListener { Project myProject; GitRepository myRepo; + private final ArrayList repoActions; RepoActions(@NotNull Project project, @NotNull GitRepository repo) { myProject = project; @@ -32,122 +30,41 @@ class RepoActions extends BranchActionGroup implements PopupElementWithAdditiona getTemplatePresentation().setText(repoName, false); // no mnemonics this.updateFavoriteIcon(); project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, this); + + repoActions = getRepoActions(); } public ArrayList getRepoActions(){ ArrayList actionList = new ArrayList(); - GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); - - - boolean noRemoteTrackBranches = false; - boolean noRemoteFeatureBranches = false; - boolean noRemoteBugfixBranches = false; - - boolean trackedAllFeatureBranches = false; - boolean trackedAllReleaseBranches = false; - boolean trackedAllBugfixBranches = false; - - String currentBranchName = GitBranchUtil.getBranchNameOrRev(myRepo); - - String featurePrefix = GitflowConfigUtil.getFeaturePrefix(myProject, myRepo); - String releasePrefix = GitflowConfigUtil.getReleasePrefix(myProject, myRepo); - String hotfixPrefix= GitflowConfigUtil.getHotfixPrefix(myProject, myRepo); - String masterBranch= GitflowConfigUtil.getMasterBranch(myProject, myRepo); - String developBranch= GitflowConfigUtil.getDevelopBranch(myProject, myRepo); - String bugfixPrefix = GitflowConfigUtil.getBugfixPrefix(myProject, myRepo); - - if (releasePrefix!=null){ - noRemoteTrackBranches = branchUtil.getRemoteBranchesWithPrefix(releasePrefix).isEmpty(); - trackedAllReleaseBranches = branchUtil.areAllBranchesTracked(releasePrefix); - } - if (featurePrefix!=null){ - noRemoteFeatureBranches = branchUtil.getRemoteBranchesWithPrefix(featurePrefix).isEmpty(); - trackedAllFeatureBranches = branchUtil.areAllBranchesTracked(featurePrefix); - } - if (bugfixPrefix!=null){ - noRemoteBugfixBranches = branchUtil.getRemoteBranchesWithPrefix(bugfixPrefix).isEmpty(); - trackedAllBugfixBranches = branchUtil.areAllBranchesTracked(bugfixPrefix); - } - - //gitflow not setup - if (branchUtil.hasGitflow()!=true){ - actionList.add(new InitRepoAction(myRepo)); - } - else{ - - //FEATURE ACTIONS - - actionList.add(new Separator("Feature")); - actionList.add(new StartFeatureAction(myRepo)); - //feature only actions - if (branchUtil.isCurrentBranchFeature()){ - actionList.add(new FinishFeatureAction(myRepo)); - - //can't publish feature if it's already published - if (branchUtil.isCurrentBranchPublished()==false){ - actionList.add(new PublishFeatureAction(myRepo)); - } - } - - //make sure there's a feature to track, and that not all features are tracked - if (noRemoteFeatureBranches == false && trackedAllFeatureBranches == false){ - actionList.add(new TrackFeatureAction(myRepo)); - } - - - //RELEASE ACTIONS - - actionList.add(new Separator("Release")); - actionList.add(new StartReleaseAction(myRepo)); - //release only actions - if (branchUtil.isCurrentBranchRelease()){ - actionList.add(new FinishReleaseAction(myRepo)); - - //can't publish release if it's already published - if (branchUtil.isCurrentBranchPublished()==false){ - actionList.add(new PublishReleaseAction(myRepo)); - } - } - - //make sure there's something to track and that not all features are tracked - if (noRemoteTrackBranches==false && trackedAllReleaseBranches ==false){ - actionList.add(new TrackReleaseAction(myRepo)); - } - - - //BUGFIX ACTIONS - - actionList.add(new Separator("Bugfix")); - actionList.add(new StartBugfixAction(myRepo)); - //bugfix only actions - if (branchUtil.isCurrentBranchBugfix()){ - actionList.add(new FinishBugfixAction(myRepo)); - - //can't publish bugfix if it's already published - if (branchUtil.isCurrentBranchPublished()==false){ - actionList.add(new PublishBugfixAction(myRepo)); - } - } - - //make sure there's a bugfix to track, and that not all bugfixes are tracked - if (noRemoteBugfixBranches == false && trackedAllBugfixBranches == false){ - actionList.add(new TrackBugfixAction(myRepo)); - } - - //HOTFIX ACTIONS - actionList.add(new Separator("Hotfix")); - - //master only actions - actionList.add(new StartHotfixAction(myRepo)); - if (branchUtil.isCurrentBranchHotfix()){ - actionList.add(new FinishHotfixAction(myRepo)); - - //can't publish hotfix if it's already published - if (branchUtil.isCurrentBranchPublished() == false) { - actionList.add(new PublishHotfixAction(myRepo)); - } - } + actionList.add(new InitRepoAction(myRepo)); + + //FEATURE ACTIONS + actionList.add(new Separator("Feature")); + actionList.add(new StartFeatureAction(myRepo)); + actionList.add(new FinishFeatureAction(myRepo)); + actionList.add(new PublishFeatureAction(myRepo)); + actionList.add(new TrackFeatureAction(myRepo)); + + //RELEASE ACTIONS + actionList.add(new Separator("Release")); + actionList.add(new StartReleaseAction(myRepo)); + actionList.add(new FinishReleaseAction(myRepo)); + actionList.add(new PublishReleaseAction(myRepo)); + actionList.add(new TrackReleaseAction(myRepo)); + + //BUGFIX ACTIONS + actionList.add(new Separator("Bugfix")); + actionList.add(new StartBugfixAction(myRepo)); + actionList.add(new FinishBugfixAction(myRepo)); + actionList.add(new PublishBugfixAction(myRepo)); + actionList.add(new TrackBugfixAction(myRepo)); + + //HOTFIX ACTIONS + actionList.add(new Separator("Hotfix")); + actionList.add(new StartHotfixAction(myRepo)); + actionList.add(new FinishHotfixAction(myRepo)); + actionList.add(new PublishHotfixAction(myRepo)); } @@ -169,8 +86,9 @@ public DefaultActionGroup getRepoActionGroup(){ @NotNull @Override public AnAction[] getChildren(@Nullable AnActionEvent e) { - ArrayList children = this.getRepoActions(); - return children.toArray(new AnAction[children.size()]); + ArrayList children = new ArrayList(this.repoActions); + + return children.toArray(new AnAction[0]); } @Override diff --git a/src/main/java/gitflow/actions/StartBugfixAction.java b/src/main/java/gitflow/actions/StartBugfixAction.java index 1c8a222..55352ea 100644 --- a/src/main/java/gitflow/actions/StartBugfixAction.java +++ b/src/main/java/gitflow/actions/StartBugfixAction.java @@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class StartBugfixAction extends GitflowAction { +public class StartBugfixAction extends AbstractStartAction { public StartBugfixAction() { super("Start Bugfix"); diff --git a/src/main/java/gitflow/actions/StartFeatureAction.java b/src/main/java/gitflow/actions/StartFeatureAction.java index 14e019d..4c9825a 100644 --- a/src/main/java/gitflow/actions/StartFeatureAction.java +++ b/src/main/java/gitflow/actions/StartFeatureAction.java @@ -5,17 +5,14 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; - -import git4idea.repo.GitRepository; -import org.jetbrains.annotations.NotNull; - import git4idea.commands.GitCommandResult; +import git4idea.repo.GitRepository; import gitflow.ui.GitflowStartFeatureDialog; import gitflow.ui.NotifyUtil; - +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class StartFeatureAction extends GitflowAction { +public class StartFeatureAction extends AbstractStartAction { public StartFeatureAction() { super("Start Feature"); diff --git a/src/main/java/gitflow/actions/StartHotfixAction.java b/src/main/java/gitflow/actions/StartHotfixAction.java index e7ae47c..c36cb40 100644 --- a/src/main/java/gitflow/actions/StartHotfixAction.java +++ b/src/main/java/gitflow/actions/StartHotfixAction.java @@ -5,18 +5,15 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; - -import git4idea.repo.GitRepository; -import org.jetbrains.annotations.NotNull; - import git4idea.commands.GitCommandResult; +import git4idea.repo.GitRepository; import gitflow.ui.GitflowStartHotfixDialog; import gitflow.ui.NotifyUtil; - +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public class StartHotfixAction extends GitflowAction { +public class StartHotfixAction extends AbstractStartAction { public StartHotfixAction(GitRepository repo) { super(repo, "Start Hotfix"); diff --git a/src/main/java/gitflow/actions/StartReleaseAction.java b/src/main/java/gitflow/actions/StartReleaseAction.java index 0c11ea6..ab50f17 100644 --- a/src/main/java/gitflow/actions/StartReleaseAction.java +++ b/src/main/java/gitflow/actions/StartReleaseAction.java @@ -10,7 +10,7 @@ import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -public class StartReleaseAction extends GitflowAction { +public class StartReleaseAction extends AbstractStartAction { StartReleaseAction() { super("Start Release"); diff --git a/src/main/java/gitflow/actions/TrackBugfixAction.java b/src/main/java/gitflow/actions/TrackBugfixAction.java index 61194cd..7aabc61 100644 --- a/src/main/java/gitflow/actions/TrackBugfixAction.java +++ b/src/main/java/gitflow/actions/TrackBugfixAction.java @@ -14,14 +14,14 @@ import java.util.ArrayList; import java.util.Iterator; -public class TrackBugfixAction extends GitflowAction { +public class TrackBugfixAction extends AbstractTrackAction { TrackBugfixAction() { - super("Track Bugfix"); + super("Track Bugfix", BranchType.Bugfix); } TrackBugfixAction(GitRepository repo) { - super(repo, "Track Bugfix"); + super(repo, "Track Bugfix", BranchType.Bugfix); } @Override diff --git a/src/main/java/gitflow/actions/TrackFeatureAction.java b/src/main/java/gitflow/actions/TrackFeatureAction.java index 3a9efc1..afdf6d4 100644 --- a/src/main/java/gitflow/actions/TrackFeatureAction.java +++ b/src/main/java/gitflow/actions/TrackFeatureAction.java @@ -14,14 +14,14 @@ import java.util.ArrayList; import java.util.Iterator; -public class TrackFeatureAction extends GitflowAction { +public class TrackFeatureAction extends AbstractTrackAction { TrackFeatureAction(){ - super("Track Feature"); + super("Track Feature", BranchType.Feature); } TrackFeatureAction(GitRepository repo){ - super(repo,"Track Feature"); + super(repo,"Track Feature", BranchType.Feature); } @Override diff --git a/src/main/java/gitflow/actions/TrackReleaseAction.java b/src/main/java/gitflow/actions/TrackReleaseAction.java index 6687b52..bf8e32c 100644 --- a/src/main/java/gitflow/actions/TrackReleaseAction.java +++ b/src/main/java/gitflow/actions/TrackReleaseAction.java @@ -13,14 +13,14 @@ import java.util.ArrayList; import java.util.Iterator; -public class TrackReleaseAction extends GitflowAction { +public class TrackReleaseAction extends AbstractTrackAction { TrackReleaseAction(){ - super("Track Release"); + super("Track Release", BranchType.Release); } TrackReleaseAction(GitRepository repo){ - super(repo,"Track Release"); + super(repo,"Track Release", BranchType.Release); } @Override From f892dda0af2df6993d3cffad45091121d8f9c34e Mon Sep 17 00:00:00 2001 From: OttNorml Date: Tue, 2 Apr 2019 10:18:27 +0200 Subject: [PATCH 04/14] Configure Gradle wrapper to use distribution with sources because it provides documentation to the IDE --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d2c45a4..a4fc03d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 47e7d6cc3591611d4b9c9b64b73fc6e1a01acb04 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Tue, 2 Apr 2019 10:25:04 +0200 Subject: [PATCH 05/14] Update sourceCompatibility to version 1.8 because any IDE younger than version 2016 (+144) runs on Java 8 (see https://intellij-support.jetbrains.com/hc/en-us/articles/206544879) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 74407e7..1a77d69 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { group 'gitflow4idea' version '0.6.7' -sourceCompatibility = 1.6 +sourceCompatibility = 1.8 repositories { mavenCentral() From 73e76b325178c82dcf4fad8f1728ac84753c58e1 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Tue, 2 Apr 2019 00:27:39 +0200 Subject: [PATCH 06/14] Update Intellij to version 2018.3.6 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1a77d69..c365450 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ dependencies { } intellij { - version '2018.3' + version '2018.3.6' plugins 'git4idea', 'tasks' } From 4c6ba1533f125832313c9aa71c3e8030a32e8794 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Tue, 2 Apr 2019 08:57:37 +0200 Subject: [PATCH 07/14] Update Intellij to version 2019.1 and org.jetbrains.intellij to version 0.4.7 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index c365450..1c51a5f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.jetbrains.intellij' version '0.3.12' + id 'org.jetbrains.intellij' version '0.4.7' } group 'gitflow4idea' @@ -17,7 +17,7 @@ dependencies { } intellij { - version '2018.3.6' + version '2019.1' plugins 'git4idea', 'tasks' } From 119d138602247b67edc4d12a1a0f8589932fcdd0 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Tue, 2 Apr 2019 11:12:53 +0200 Subject: [PATCH 08/14] Update plugin upper build number range to version 191.* --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1c51a5f..319c027 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ patchPluginXml { pluginDescription 'Git Flow Integration' version '0.6.7' sinceBuild '182.0' - untilBuild '183.*' + untilBuild '191.*' changeNotes """

Changelog for 0.6.7

    From a9b7103bad5f323ab1506757963b09e0bce4bb32 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Sat, 6 Apr 2019 01:26:08 +0200 Subject: [PATCH 09/14] Add targetCompatibility to Gradle build config --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 319c027..ce09cce 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,8 @@ plugins { group 'gitflow4idea' version '0.6.7' -sourceCompatibility = 1.8 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 repositories { mavenCentral() From 4b9722fe2a769fe839e5fe96b8596da45a389975 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Sat, 6 Apr 2019 01:41:26 +0200 Subject: [PATCH 10/14] Enable Xlint --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ce09cce..1193ad0 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,10 @@ plugins { id 'org.jetbrains.intellij' version '0.4.7' } +compileJava { + options.compilerArgs += ["-Xlint"] +} + group 'gitflow4idea' version '0.6.7' @@ -40,4 +44,4 @@ patchPluginXml {

    Note - if you see 'no gitflow' in the status bar you will need to re-init using git flow init -f

    """ -} \ No newline at end of file +} From 3df76624bb05dc2bce50796cf9b371484ff478b1 Mon Sep 17 00:00:00 2001 From: OttNorml Date: Sat, 6 Apr 2019 01:51:21 +0200 Subject: [PATCH 11/14] Update Gradle to version 5.3.1 --- gradle/wrapper/gradle-wrapper.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4fc03d..b04b400 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Tue Apr 06 01:50:18 CEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip From 56d94ad68139c9832ba8a205a5dfc1000c4357ae Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Sat, 6 Apr 2019 08:57:31 +0300 Subject: [PATCH 12/14] Re-add .idea folder to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8d169af..71cd570 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,5 @@ fabric.properties # GitEye project file /.project + +.idea \ No newline at end of file From ff5b3c1c994943e80cc6e53667cb042d632bcbdd Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Sat, 6 Apr 2019 09:50:48 +0300 Subject: [PATCH 13/14] Fix typo --- src/main/java/gitflow/actions/RepoActions.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/gitflow/actions/RepoActions.java b/src/main/java/gitflow/actions/RepoActions.java index e5fbed9..e400e79 100644 --- a/src/main/java/gitflow/actions/RepoActions.java +++ b/src/main/java/gitflow/actions/RepoActions.java @@ -66,8 +66,6 @@ public ArrayList getRepoActions(){ actionList.add(new FinishHotfixAction(myRepo)); actionList.add(new PublishHotfixAction(myRepo)); - } - return actionList; } From 79736f9c6f84abfc80833d24e75015a83401af6e Mon Sep 17 00:00:00 2001 From: OpherV Date: Sat, 6 Apr 2019 20:30:52 +0300 Subject: [PATCH 14/14] Update metadata for 0.6.8 --- build.gradle | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 1193ad0..c8c2bb3 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ compileJava { } group 'gitflow4idea' -version '0.6.7' +version '0.6.8' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -33,13 +33,10 @@ patchPluginXml { sinceBuild '182.0' untilBuild '191.*' changeNotes """ -

    Changelog for 0.6.7

    +

    Changelog for 0.6.8

      -
    • Support for Idea build 183 #210 (@opherv)
    • -
    • Feature: Bugfix support #122 (@straurob)
    • -
    • Feature: pushOnFinish to feature options (@bmwsedee)
    • -
    • Bugfix UI freeze on custom gitflow init #198 (@bmwsedee)
    • -
    • Implementation: plugin is now built with gradle (@straurob)
    • +
    • Support for Idea build 191 #221 (@ottnorml)
    • +
    • Fix performance issues in plugin #195 (@bmwsedee)

    Note - if you see 'no gitflow' in the status bar you will need to re-init using git flow init -f