Skip to content

Commit

Permalink
Merge branch 'release/0.6.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Apr 6, 2019
2 parents 1147fb8 + 79736f9 commit 4a8af8f
Show file tree
Hide file tree
Showing 26 changed files with 359 additions and 232 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ fabric.properties

# GitEye project file
/.project

.idea
26 changes: 14 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
id 'org.jetbrains.intellij' version '0.4.7'
}

compileJava {
options.compilerArgs += ["-Xlint"]
}

group 'gitflow4idea'
version '0.6.7'
version '0.6.8'

sourceCompatibility = 1.6
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
Expand All @@ -17,7 +22,7 @@ dependencies {
}

intellij {
version '2018.3'
version '2019.1'
plugins 'git4idea', 'tasks'
}

Expand All @@ -26,17 +31,14 @@ patchPluginXml {
pluginDescription 'Git Flow Integration'
version '0.6.7'
sinceBuild '182.0'
untilBuild '183.*'
untilBuild '191.*'
changeNotes """
<H2>Changelog for 0.6.7</H2>
<H2>Changelog for 0.6.8</H2>
<ul>
<li>Support for Idea build 183 #210 (@opherv)</li>
<li>Feature: Bugfix support #122 (@straurob)</li>
<li>Feature: pushOnFinish to feature options (@bmwsedee)</li>
<li>Bugfix UI freeze on custom gitflow init #198 (@bmwsedee)</li>
<li>Implementation: plugin is now built with gradle (@straurob)</li>
<li>Support for Idea build 191 #221 (@ottnorml)</li>
<li>Fix performance issues in plugin #195 (@bmwsedee)</li>
</ul>
<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>
"""
}
}
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
118 changes: 77 additions & 41 deletions src/main/java/gitflow/GitflowBranchUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ 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<GitRemoteBranch> remoteBranches;
private ArrayList<String> remoteBranchNames;
private ArrayList<GitLocalBranch> localBranches;
private ArrayList<String> localBranchNames;

public GitflowBranchUtil(Project project, GitRepository repo){
myProject=project;
Expand All @@ -38,27 +43,57 @@ 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);
prefixBugfix = GitflowConfigUtil.getBugfixPrefix(project, repo);

initRemoteBranches();
initLocalBranchNames();
}
}

public boolean hasGitflow(){
boolean hasGitflow=false;
public String getCurrentBranchName() {
return currentBranchName;
}

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;
public boolean hasGitflow(){
boolean hasGitflow = myRepo != null
&& branchnameMaster != null
&& branchnameDevelop != null
&& prefixFeature != null
&& prefixRelease != null
&& prefixHotfix != null
&& prefixBugfix != null;

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);
}
Expand Down Expand Up @@ -97,9 +132,31 @@ public boolean isBranchBugfix(String branchName){
return branchName.startsWith(prefixBugfix);
}

private void initRemoteBranches() {
remoteBranches =
new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());
remoteBranchNames = new ArrayList<String>();

for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
GitRemoteBranch branch = i.next();
remoteBranchNames.add(branch.getName());
}
}

private void initLocalBranchNames(){
localBranches =
new ArrayList<GitLocalBranch>(myRepo.getBranches().getLocalBranches());
localBranchNames = new ArrayList<String>();

for(Iterator<GitLocalBranch> i = localBranches.iterator(); i.hasNext(); ) {
GitLocalBranch branch = i.next();
localBranchNames.add(branch.getName());
}
}

//if no prefix specified, returns all remote branches
public ArrayList<String> getRemoteBranchesWithPrefix(String prefix){
ArrayList<String> remoteBranches = getRemoteBranchNames();
ArrayList<String> remoteBranches = remoteBranchNames;
ArrayList<String> selectedBranches = new ArrayList<String>();

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

public ArrayList<String> getRemoteBranchNames(){
ArrayList<GitRemoteBranch> remoteBranches = new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());
ArrayList<String> branchNameList = new ArrayList<String>();

for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
GitRemoteBranch branch = i.next();
branchNameList.add(branch.getName());
}

return branchNameList;
return remoteBranchNames;
}


public ArrayList<String> getLocalBranchNames(){
ArrayList<GitLocalBranch> localBranches = new ArrayList<GitLocalBranch>(myRepo.getBranches().getLocalBranches());
ArrayList<String> branchNameList = new ArrayList<String>();

for(Iterator<GitLocalBranch> i = localBranches.iterator(); i.hasNext(); ) {
GitLocalBranch branch = i.next();
branchNameList.add(branch.getName());
}

return branchNameList;
public ArrayList<String> getLocalBranchNames() {
return localBranchNames;
}



public GitRemote getRemoteByBranch(String branchName){
GitRemote remote=null;

ArrayList<GitRemoteBranch> remoteBranches= new ArrayList<GitRemoteBranch>(myRepo.getBranches().getRemoteBranches());

for(Iterator<GitRemoteBranch> i = remoteBranches.iterator(); i.hasNext(); ) {
GitRemoteBranch branch = i.next();
if (branch.getName()==branchName){
if (branch.getName().equals(branchName)){
remote=branch.getRemote();
break;
}
Expand Down
60 changes: 60 additions & 0 deletions src/main/java/gitflow/actions/AbstractBranchAction.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
22 changes: 22 additions & 0 deletions src/main/java/gitflow/actions/AbstractPublishAction.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
30 changes: 30 additions & 0 deletions src/main/java/gitflow/actions/AbstractStartAction.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
36 changes: 36 additions & 0 deletions src/main/java/gitflow/actions/AbstractTrackAction.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit 4a8af8f

Please sign in to comment.