Skip to content

Commit 4a8af8f

Browse files
committed
Merge branch 'release/0.6.8'
2 parents 1147fb8 + 79736f9 commit 4a8af8f

26 files changed

+359
-232
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ fabric.properties
102102

103103
# GitEye project file
104104
/.project
105+
106+
.idea

build.gradle

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.intellij' version '0.3.12'
3+
id 'org.jetbrains.intellij' version '0.4.7'
4+
}
5+
6+
compileJava {
7+
options.compilerArgs += ["-Xlint"]
48
}
59

610
group 'gitflow4idea'
7-
version '0.6.7'
11+
version '0.6.8'
812

9-
sourceCompatibility = 1.6
13+
sourceCompatibility = JavaVersion.VERSION_1_8
14+
targetCompatibility = JavaVersion.VERSION_1_8
1015

1116
repositories {
1217
mavenCentral()
@@ -17,7 +22,7 @@ dependencies {
1722
}
1823

1924
intellij {
20-
version '2018.3'
25+
version '2019.1'
2126
plugins 'git4idea', 'tasks'
2227
}
2328

@@ -26,17 +31,14 @@ patchPluginXml {
2631
pluginDescription 'Git Flow Integration'
2732
version '0.6.7'
2833
sinceBuild '182.0'
29-
untilBuild '183.*'
34+
untilBuild '191.*'
3035
changeNotes """
31-
<H2>Changelog for 0.6.7</H2>
36+
<H2>Changelog for 0.6.8</H2>
3237
<ul>
33-
<li>Support for Idea build 183 #210 (@opherv)</li>
34-
<li>Feature: Bugfix support #122 (@straurob)</li>
35-
<li>Feature: pushOnFinish to feature options (@bmwsedee)</li>
36-
<li>Bugfix UI freeze on custom gitflow init #198 (@bmwsedee)</li>
37-
<li>Implementation: plugin is now built with gradle (@straurob)</li>
38+
<li>Support for Idea build 191 #221 (@ottnorml)</li>
39+
<li>Fix performance issues in plugin #195 (@bmwsedee)</li>
3840
</ul>
3941
4042
<p>Note - if you see 'no gitflow' in the status bar you will need to re-init using <code>git flow init -f</code></p>
4143
"""
42-
}
44+
}
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Tue Apr 06 01:50:18 CEST 2019
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip

src/main/java/gitflow/GitflowBranchUtil.java

+77-41
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ public class GitflowBranchUtil {
2323
Project myProject;
2424
GitRepository myRepo;
2525

26-
String currentBranchName;
27-
String branchnameMaster;
28-
String prefixFeature;
29-
String prefixRelease;
30-
String prefixHotfix;
31-
String prefixBugfix;
26+
private String currentBranchName;
27+
private String branchnameMaster;
28+
private String branchnameDevelop;
29+
private String prefixFeature;
30+
private String prefixRelease;
31+
private String prefixHotfix;
32+
private String prefixBugfix;
33+
private ArrayList<GitRemoteBranch> remoteBranches;
34+
private ArrayList<String> remoteBranchNames;
35+
private ArrayList<GitLocalBranch> localBranches;
36+
private ArrayList<String> localBranchNames;
3237

3338
public GitflowBranchUtil(Project project, GitRepository repo){
3439
myProject=project;
@@ -38,27 +43,57 @@ public GitflowBranchUtil(Project project, GitRepository repo){
3843
currentBranchName = GitBranchUtil.getBranchNameOrRev(repo);
3944

4045
branchnameMaster= GitflowConfigUtil.getMasterBranch(project, repo);
46+
branchnameDevelop = GitflowConfigUtil.getDevelopBranch(project, repo);
4147
prefixFeature = GitflowConfigUtil.getFeaturePrefix(project, repo);
4248
prefixRelease = GitflowConfigUtil.getReleasePrefix(project, repo);
4349
prefixHotfix = GitflowConfigUtil.getHotfixPrefix(project, repo);
4450
prefixBugfix = GitflowConfigUtil.getBugfixPrefix(project, repo);
51+
52+
initRemoteBranches();
53+
initLocalBranchNames();
4554
}
4655
}
4756

48-
public boolean hasGitflow(){
49-
boolean hasGitflow=false;
57+
public String getCurrentBranchName() {
58+
return currentBranchName;
59+
}
5060

51-
hasGitflow = myRepo != null
52-
&& GitflowConfigUtil.getMasterBranch(myProject, myRepo)!=null
53-
&& GitflowConfigUtil.getDevelopBranch(myProject, myRepo)!=null
54-
&& GitflowConfigUtil.getFeaturePrefix(myProject, myRepo)!=null
55-
&& GitflowConfigUtil.getReleasePrefix(myProject, myRepo)!=null
56-
&& GitflowConfigUtil.getHotfixPrefix(myProject, myRepo)!=null
57-
&& GitflowConfigUtil.getBugfixPrefix(myProject, myRepo)!=null;
61+
public boolean hasGitflow(){
62+
boolean hasGitflow = myRepo != null
63+
&& branchnameMaster != null
64+
&& branchnameDevelop != null
65+
&& prefixFeature != null
66+
&& prefixRelease != null
67+
&& prefixHotfix != null
68+
&& prefixBugfix != null;
5869

5970
return hasGitflow;
6071
}
6172

73+
public String getBranchnameMaster() {
74+
return branchnameMaster;
75+
}
76+
77+
public String getBranchnameDevelop() {
78+
return branchnameDevelop;
79+
}
80+
81+
public String getPrefixFeature() {
82+
return prefixFeature;
83+
}
84+
85+
public String getPrefixRelease() {
86+
return prefixRelease;
87+
}
88+
89+
public String getPrefixHotfix() {
90+
return prefixHotfix;
91+
}
92+
93+
public String getPrefixBugfix() {
94+
return prefixBugfix;
95+
}
96+
6297
public boolean isCurrentBranchMaster(){
6398
return currentBranchName.startsWith(branchnameMaster);
6499
}
@@ -97,9 +132,31 @@ public boolean isBranchBugfix(String branchName){
97132
return branchName.startsWith(prefixBugfix);
98133
}
99134

135+
private void initRemoteBranches() {
136+
remoteBranches =
137+
new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());
138+
remoteBranchNames = new ArrayList<String>();
139+
140+
for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
141+
GitRemoteBranch branch = i.next();
142+
remoteBranchNames.add(branch.getName());
143+
}
144+
}
145+
146+
private void initLocalBranchNames(){
147+
localBranches =
148+
new ArrayList<GitLocalBranch>(myRepo.getBranches().getLocalBranches());
149+
localBranchNames = new ArrayList<String>();
150+
151+
for(Iterator<GitLocalBranch> i = localBranches.iterator(); i.hasNext(); ) {
152+
GitLocalBranch branch = i.next();
153+
localBranchNames.add(branch.getName());
154+
}
155+
}
156+
100157
//if no prefix specified, returns all remote branches
101158
public ArrayList<String> getRemoteBranchesWithPrefix(String prefix){
102-
ArrayList<String> remoteBranches = getRemoteBranchNames();
159+
ArrayList<String> remoteBranches = remoteBranchNames;
103160
ArrayList<String> selectedBranches = new ArrayList<String>();
104161

105162
for(Iterator<String> i = remoteBranches.iterator(); i.hasNext(); ) {
@@ -127,40 +184,19 @@ public ArrayList<String> filterBranchListByPrefix(Collection<String> inputBranch
127184
}
128185

129186
public ArrayList<String> getRemoteBranchNames(){
130-
ArrayList<GitRemoteBranch> remoteBranches = new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());
131-
ArrayList<String> branchNameList = new ArrayList<String>();
132-
133-
for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
134-
GitRemoteBranch branch = i.next();
135-
branchNameList.add(branch.getName());
136-
}
137-
138-
return branchNameList;
187+
return remoteBranchNames;
139188
}
140189

141-
142-
public ArrayList<String> getLocalBranchNames(){
143-
ArrayList<GitLocalBranch> localBranches = new ArrayList<GitLocalBranch>(myRepo.getBranches().getLocalBranches());
144-
ArrayList<String> branchNameList = new ArrayList<String>();
145-
146-
for(Iterator<GitLocalBranch> i = localBranches.iterator(); i.hasNext(); ) {
147-
GitLocalBranch branch = i.next();
148-
branchNameList.add(branch.getName());
149-
}
150-
151-
return branchNameList;
190+
public ArrayList<String> getLocalBranchNames() {
191+
return localBranchNames;
152192
}
153193

154-
155-
156194
public GitRemote getRemoteByBranch(String branchName){
157195
GitRemote remote=null;
158196

159-
ArrayList<GitRemoteBranch> remoteBranches= new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());
160-
161197
for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
162198
GitRemoteBranch branch = i.next();
163-
if (branch.getName()==branchName){
199+
if (branch.getName().equals(branchName)){
164200
remote=branch.getRemote();
165201
break;
166202
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package gitflow.actions;
2+
3+
import com.intellij.openapi.actionSystem.AnActionEvent;
4+
import git4idea.repo.GitRepository;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
public abstract class AbstractBranchAction extends GitflowAction {
8+
enum BranchType {
9+
Feature, Release, Bugfix, Hotfix
10+
}
11+
12+
BranchType type;
13+
14+
AbstractBranchAction(String actionName, BranchType type) {
15+
super(actionName);
16+
this.type = type;
17+
}
18+
19+
AbstractBranchAction(GitRepository repo, String actionName, BranchType type) {
20+
super(repo, actionName);
21+
this.type = type;
22+
}
23+
24+
25+
@Override
26+
public void update(@NotNull AnActionEvent e) {
27+
if (branchUtil == null) {
28+
e.getPresentation().setEnabledAndVisible(false);
29+
return;
30+
}
31+
32+
//Disable and hide when gitflow has not been setup
33+
if (branchUtil.hasGitflow() == false) {
34+
e.getPresentation().setEnabledAndVisible(false);
35+
return;
36+
}
37+
38+
//Disable and hide when the branch-type is incorrect
39+
if (isActionAllowedForBranch() == false) {
40+
e.getPresentation().setEnabledAndVisible(false);
41+
} else {
42+
e.getPresentation().setEnabledAndVisible(true);
43+
}
44+
}
45+
46+
protected boolean isActionAllowedForBranch() {
47+
switch (type) {
48+
case Feature:
49+
return branchUtil.isCurrentBranchFeature();
50+
case Release:
51+
return branchUtil.isCurrentBranchRelease();
52+
case Bugfix:
53+
return branchUtil.isCurrentBranchBugfix();
54+
case Hotfix:
55+
return branchUtil.isCurrentBranchHotfix();
56+
default:
57+
return false;
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package gitflow.actions;
2+
3+
import git4idea.repo.GitRepository;
4+
5+
public abstract class AbstractPublishAction extends AbstractBranchAction {
6+
AbstractPublishAction(String actionName, BranchType type) {
7+
super(actionName, type);
8+
}
9+
10+
AbstractPublishAction(GitRepository repo, String actionName, BranchType type) {
11+
super(repo, actionName, type);
12+
}
13+
14+
@Override
15+
protected boolean isActionAllowedForBranch() {
16+
if (!super.isActionAllowedForBranch()) {
17+
return false;
18+
}
19+
20+
return !branchUtil.isCurrentBranchPublished();
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package gitflow.actions;
2+
3+
import com.intellij.openapi.actionSystem.AnActionEvent;
4+
import git4idea.repo.GitRepository;
5+
import gitflow.GitflowBranchUtil;
6+
import gitflow.GitflowBranchUtilManager;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
public abstract class AbstractStartAction extends GitflowAction {
10+
AbstractStartAction(String actionName) {
11+
super(actionName);
12+
}
13+
14+
AbstractStartAction(GitRepository repo, String actionName) {
15+
super(repo, actionName);
16+
}
17+
18+
19+
@Override
20+
public void update(@NotNull AnActionEvent e) {
21+
GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo);
22+
23+
//Disable and hide when gitflow has not been setup
24+
if (branchUtil.hasGitflow() == false) {
25+
e.getPresentation().setEnabledAndVisible(false);
26+
} else {
27+
e.getPresentation().setEnabledAndVisible(true);
28+
}
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package gitflow.actions;
2+
3+
import git4idea.repo.GitRepository;
4+
5+
public abstract class AbstractTrackAction extends AbstractBranchAction {
6+
AbstractTrackAction(String actionName, BranchType type) {
7+
super(actionName, type);
8+
}
9+
10+
AbstractTrackAction(GitRepository repo, String actionName, BranchType type) {
11+
super(repo, actionName, type);
12+
}
13+
14+
@Override
15+
protected boolean isActionAllowedForBranch() {
16+
String prefix;
17+
switch (type) {
18+
case Feature:
19+
prefix = featurePrefix;
20+
break;
21+
case Release:
22+
prefix = releasePrefix;
23+
break;
24+
case Bugfix:
25+
prefix = bugfixPrefix;
26+
break;
27+
default:
28+
return false;
29+
}
30+
31+
boolean noRemoteBranches = branchUtil.getRemoteBranchesWithPrefix(prefix).isEmpty();
32+
boolean trackedAllBranches = branchUtil.areAllBranchesTracked(prefix);
33+
34+
return noRemoteBranches == false && trackedAllBranches == false;
35+
}
36+
}

0 commit comments

Comments
 (0)