Skip to content

Commit

Permalink
Merge branch 'release/0.7.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Apr 13, 2021
2 parents 5b29fd8 + abd4f8c commit f81695c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 37 deletions.
17 changes: 12 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ compileJava {
}

group 'gitflow4idea'
version '0.7.5'
version '0.7.6'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -22,18 +22,25 @@ dependencies {
}

intellij {
version '2020.3'
version '2021.1'
plugins 'git4idea', 'tasks'
}

patchPluginXml {
pluginId "Gitflow"
pluginDescription 'Git Flow Integration'
version '0.7.5'
sinceBuild '203.0'
untilBuild '203.*'
version '0.7.6'
sinceBuild '211.0'
untilBuild '211.*'
changeNotes """
<H2>Changelog for 0.7.6</H2>
<ul>
<li>Fix "Error using shortcuts" #322</li>
<li>fix Finishing BugFix throws stacktrace #320</li>
<li>Support for 2021.1 build</li>
</ul>
<H2>Changelog for 0.7.5</H2>
<ul>
<li>PluginException: Icon cannot be found in 'AllIcons.Vcs.CheckOut' #314 (@tumb1er)</li>
Expand Down
21 changes: 6 additions & 15 deletions src/main/java/gitflow/GitflowBranchUtilManager.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,44 @@
package gitflow;

import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import git4idea.GitUtil;
import git4idea.repo.GitRepository;
import gitflow.actions.GitflowActions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Future;

/**
* This class maps repos to their corresponding branch utils
* Note that the static class is used across projects
*/

public class GitflowBranchUtilManager {
private static HashMap<GitRepository, GitflowBranchUtil> repoBranchUtilMap;
private static HashMap<String, GitflowBranchUtil> repoBranchUtilMap;

static public GitflowBranchUtil getBranchUtil(GitRepository repo){
if (repoBranchUtilMap != null) {
return repoBranchUtilMap.get(repo);
if (repo != null && repoBranchUtilMap != null) {
return repoBranchUtilMap.get(repo.getPresentableUrl());
} else {
return null;
}
}

static public void setupBranchUtil(Project project, GitRepository repo){
GitflowBranchUtil gitflowBranchUtil = new GitflowBranchUtil(project, repo);
repoBranchUtilMap.put(repo, gitflowBranchUtil);
repoBranchUtilMap.put(repo.getPresentableUrl(), gitflowBranchUtil);
// clean up
Disposer.register(repo, () -> repoBranchUtilMap.remove(repo));
}

/**
* Repopulates the branchUtils for each repo
* @param project
* @param proj
*/
static public void update(Project proj){
if (repoBranchUtilMap == null){
repoBranchUtilMap = new HashMap<GitRepository, gitflow.GitflowBranchUtil>();
repoBranchUtilMap = new HashMap<String, gitflow.GitflowBranchUtil>();
}

List<GitRepository> gitRepositories = GitUtil.getRepositoryManager(proj).getRepositories();
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/gitflow/GitflowConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import git4idea.config.GitConfigUtil;
import git4idea.repo.GitRepository;
import gitflow.ui.NotifyUtil;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -31,7 +32,7 @@ public class GitflowConfigUtil {
public static final String PREFIX_SUPPORT = "gitflow.prefix.support";
public static final String PREFIX_VERSIONTAG = "gitflow.prefix.versiontag";

private static Map<Project, Map<GitRepository, GitflowConfigUtil>> gitflowConfigUtilMap = new HashMap<Project, Map<GitRepository, GitflowConfigUtil>>();
private static Map<Project, Map<String, GitflowConfigUtil>> gitflowConfigUtilMap = new HashMap<Project, Map<String, GitflowConfigUtil>>();

Project project;
GitRepository repo;
Expand All @@ -44,17 +45,17 @@ public class GitflowConfigUtil {
public String supportPrefix;
public String versiontagPrefix;

public static GitflowConfigUtil getInstance(Project project_, GitRepository repo_)
public static GitflowConfigUtil getInstance(@NotNull Project project_, @NotNull GitRepository repo_)
{
GitflowConfigUtil instance;
if (gitflowConfigUtilMap.containsKey(project_) && gitflowConfigUtilMap.get(project_).containsKey(repo_)) {
instance = gitflowConfigUtilMap.get(project_).get(repo_);
if (gitflowConfigUtilMap.containsKey(project_) && gitflowConfigUtilMap.get(project_).containsKey(repo_.getPresentableUrl())) {
instance = gitflowConfigUtilMap.get(project_).get(repo_.getPresentableUrl());
} else {
Map<GitRepository, GitflowConfigUtil> innerMap = new HashMap<GitRepository, GitflowConfigUtil>();
Map<String, GitflowConfigUtil> innerMap = new HashMap<String, GitflowConfigUtil>();
instance = new GitflowConfigUtil(project_, repo_);

gitflowConfigUtilMap.put(project_, innerMap);
innerMap.put(repo_, instance);
innerMap.put(repo_.getPresentableUrl(), instance);

//cleanup
Disposer.register(repo_, () -> innerMap.remove(repo_));
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/gitflow/IDEAUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package gitflow;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.wm.WindowManager;

import java.awt.*;

public class IDEAUtils {
public static Project getActiveProject(){
Project[] projects = ProjectManager.getInstance().getOpenProjects();
Project activeProject = null;
for (Project project : projects) {
Window window = WindowManager.getInstance().suggestParentWindow(project);
if (window != null && window.isActive()) {
activeProject = project;
}
}
return activeProject;
}
}
6 changes: 3 additions & 3 deletions src/main/java/gitflow/actions/FinishBugfixAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public void runAction(final Project project, final String bugfixName){

GitflowConfigUtil gitflowConfigUtil = GitflowConfigUtil.getInstance(project, myRepo);

//get the base branch for this bugfix
final String baseBranch = gitflowConfigUtil.getBaseBranch(branchUtil.getPrefixBugfix()+bugfixName);

new Task.Backgroundable(myProject,"Finishing bugfix "+bugfixName,false){
@Override
public void run(@NotNull ProgressIndicator indicator) {
GitCommandResult result = myGitflow.finishBugfix(myRepo, bugfixName, errorLineHandler);

//get the base branch for this bugfix
final String baseBranch = gitflowConfigUtil.getBaseBranch(branchUtil.getPrefixBugfix()+bugfixName);

if (result.success()) {
String finishedBugfixMessage = String.format("The bugfix branch '%s%s' was merged into '%s'", branchUtil.getPrefixBugfix(), bugfixName, baseBranch);
NotifyUtil.notifySuccess(myProject, bugfixName, finishedBugfixMessage);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gitflow/actions/GitflowAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gitflow.Gitflow;
import gitflow.GitflowBranchUtil;
import gitflow.GitflowBranchUtilManager;
import gitflow.IDEAUtils;
import gitflow.ui.NotifyUtil;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -41,7 +42,7 @@ public abstract class GitflowAction extends DumbAwareAction {

@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
Project project = IDEAUtils.getActiveProject();

// if repo isn't set explicitly, such as in the case of starting from keyboard shortcut, infer it
if (myRepo == null){
Expand Down
26 changes: 20 additions & 6 deletions src/main/java/gitflow/ui/GitflowWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
package gitflow.ui;

import com.intellij.ide.BrowserUtil;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.impl.SimpleDataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
Expand All @@ -25,18 +27,19 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.ListPopup;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.StatusBarWidget;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.impl.status.EditorBasedWidget;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.PopupFactoryImpl;
import com.intellij.util.Consumer;
import com.intellij.openapi.vcs.VcsRoot;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;

import gitflow.GitflowBranchUtil;
import gitflow.GitflowBranchUtilManager;
import gitflow.GitflowVersionTester;
import git4idea.GitBranch;
import gitflow.*;
import gitflow.actions.GitflowPopupGroup;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -107,9 +110,10 @@ public void repositoryChanged(@NotNull GitRepository repository) {
}

@Nullable
@Override
@ Override
public ListPopup getPopupStep() {
Project project = getProject();
Project project = IDEAUtils.getActiveProject();

if (project == null) {
return null;
}
Expand All @@ -118,7 +122,17 @@ public ListPopup getPopupStep() {
return null;
}

ListPopup listPopup = new PopupFactoryImpl.ActionGroupPopup("Gitflow Actions", popupGroup.getActionGroup(), SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1,
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (focusOwner == null) {
IdeFocusManager focusManager = IdeFocusManager.getInstance(project);
Window frame = focusManager.getLastFocusedIdeWindow();
if (frame != null) {
focusOwner = focusManager.getLastFocusedFor(frame);
}
}

DataContext dataContext = DataManager.getInstance().getDataContext(focusOwner);
ListPopup listPopup = new PopupFactoryImpl.ActionGroupPopup("Gitflow Actions", popupGroup.getActionGroup(), dataContext, false, false, false, true, null, -1,
null, null);

return listPopup;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

<group id="Gitflow.Menu" popup="true" text="Gitflow"
class="gitflow.GitflowMenu">
<add-to-group group-id="Git.Menu" />
<add-to-group group-id="Git.MainMenu" />
</group>
</actions>

Expand Down

0 comments on commit f81695c

Please sign in to comment.