Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/intellij15' into intellij2016.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	src/main/java/com/urswolfer/intellij/plugin/gerrit/OpenIdeDependenciesModule.java
#	src/main/java/com/urswolfer/intellij/plugin/gerrit/git/GerritGitUtil.java
#	src/test/java/com/urswolfer/intellij/plugin/gerrit/rest/GerritTestModule.java
  • Loading branch information
uwolfer committed Feb 28, 2021
2 parents 4abc0b4 + f316489 commit 1e4aeb0
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

plugins {
id 'org.jetbrains.intellij' version '0.6.3'
id 'org.jetbrains.intellij' version '0.7.2'
}

apply plugin: 'java'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ideaVersion=IC-2016.2.5
ijPluginRepoChannel=
downloadIdeaSources=false
version=1.2.3-146
version=1.2.4-146
javaVersion=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ protected void configure() {
bind(LocalFileSystem.class).toInstance(LocalFileSystem.getInstance());

bind(Git.class).toInstance(ServiceManager.getService(Git.class));
bind(FileDocumentManager.class).toInstance(FileDocumentManager.getInstance());
bind(VirtualFileManager.class).toInstance(VirtualFileManager.getInstance());

bind(ShowSettingsUtil.class).toInstance(ShowSettingsUtil.getInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.inject.Inject;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.CheckoutProvider;
import com.intellij.openapi.vcs.VcsKey;
Expand All @@ -43,7 +44,6 @@
import com.urswolfer.intellij.plugin.gerrit.rest.GerritUtil;
import com.urswolfer.intellij.plugin.gerrit.util.NotificationBuilder;
import com.urswolfer.intellij.plugin.gerrit.util.NotificationService;
import git4idea.actions.BasicAction;
import git4idea.checkout.GitCheckoutProvider;
import git4idea.checkout.GitCloneDialog;
import git4idea.commands.Git;
Expand Down Expand Up @@ -89,7 +89,7 @@ public void doCheckout(@NotNull final Project project, @Nullable final Listener
if (!gerritUtil.testGitExecutable(project)) {
return;
}
BasicAction.saveAll();
FileDocumentManager.getInstance().saveAllDocuments();
List<ProjectInfo> availableProjects = null;
try {
availableProjects = gerritUtil.getAvailableProjects(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import com.urswolfer.intellij.plugin.gerrit.util.NotificationService;
import com.urswolfer.intellij.plugin.gerrit.util.UrlUtils;
import git4idea.GitCommit;
import git4idea.GitExecutionException;
import git4idea.GitUtil;
import git4idea.GitVcs;
import git4idea.commands.Git;
Expand Down Expand Up @@ -86,8 +85,6 @@ public class GerritGitUtil {
@Inject
private Git git;
@Inject
private FileDocumentManager fileDocumentManager;
@Inject
private Application application;
@Inject
private VirtualFileManager virtualFileManager;
Expand Down Expand Up @@ -143,20 +140,8 @@ public void fetchChange(final Project project,
final GitRepository gitRepository,
final FetchInfo fetchInfo,
final String commitHash,
@Nullable final Callable<Void> successCallable) {
@Nullable final Callable<Void> fetchCallback) {
GitVcs.runInBackground(new Task.Backgroundable(project, "Fetching...", false) {
@Override
public void onSuccess() {
super.onSuccess();
try {
if (successCallable != null) {
successCallable.call();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@Override
public void run(@NotNull ProgressIndicator indicator) {
GitRemote remote;
Expand All @@ -178,12 +163,20 @@ public void run(@NotNull ProgressIndicator indicator) {
if (!result.isSuccess()) {
GitFetcher.displayFetchResult(project, result, null, result.getErrors());
}

try {
if (fetchCallback != null) {
fetchCallback.call();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}

public void cherryPickChange(final Project project, final ChangeInfo changeInfo, final String revisionId) {
fileDocumentManager.saveAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
ChangeListManagerImpl.getInstanceImpl(project).blockModalNotifications();

new Task.Backgroundable(project, "Cherry-picking...", false) {
Expand Down Expand Up @@ -364,7 +357,7 @@ public Pair<List<GitCommit>, List<GitCommit>> loadCommitsToCompare(@NotNull GitR
branchToHead = GitHistoryUtils.history(project, repository.getRoot(), branchName + "..");
} catch (VcsException e) {
// we treat it as critical and report an error
throw new GitExecutionException("Couldn't get [git log .." + branchName + "] on repository [" + repository.getRoot() + "]", e);
throw new RuntimeException("Couldn't get [git log .." + branchName + "] on repository [" + repository.getRoot() + "]", e);
}
return Pair.create(headToBranch, branchToHead);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SafeHtmlTextEditor(Project project) {
TabbedPaneImpl tabbedPane = new TabbedPaneImpl(SwingConstants.TOP);
tabbedPane.setKeyboardNavigation(TabbedPaneImpl.DEFAULT_PREV_NEXT_SHORTCUTS);

messageField = CommitMessage.createCommitTextEditor(project, false);
messageField = new CommitMessage(project).getEditorField();
messageField.setBorder(BorderFactory.createEmptyBorder());
JPanel messagePanel = new JPanel(new BorderLayout());
messagePanel.add(messageField, BorderLayout.CENTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.util.Consumer;
Expand All @@ -33,10 +36,12 @@
import com.urswolfer.intellij.plugin.gerrit.git.GerritGitUtil;
import com.urswolfer.intellij.plugin.gerrit.util.NotificationBuilder;
import com.urswolfer.intellij.plugin.gerrit.util.NotificationService;
import git4idea.GitVcs;
import git4idea.branch.GitBrancher;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
import git4idea.validators.GitNewBranchNameValidator;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -71,10 +76,10 @@ public void actionPerformed(final AnActionEvent anActionEvent) {
getChangeDetail(selectedChange.get(), project, new Consumer<ChangeInfo>() {
@Override
public void consume(final ChangeInfo changeDetails) {
Callable<Void> successCallable = new Callable<Void>() {
Callable<Void> fetchCallback = new Callable<Void>() {
@Override
public Void call() throws Exception {
GitBrancher brancher = ServiceManager.getService(project, GitBrancher.class);
final GitBrancher brancher = ServiceManager.getService(project, GitBrancher.class);
Optional<GitRepository> gitRepositoryOptional = gerritGitUtil.
getRepositoryForGerritProject(project, changeDetails.project);
if (!gitRepositoryOptional.isPresent()) {
Expand All @@ -86,7 +91,7 @@ public Void call() throws Exception {
String branchName = buildBranchName(changeDetails);
String checkedOutBranchName = branchName;
final GitRepository repository = gitRepositoryOptional.get();
List<GitRepository> gitRepositories = Collections.singletonList(repository);
final List<GitRepository> gitRepositories = Collections.singletonList(repository);
FetchInfo firstFetchInfo = gerritUtil.getFirstFetchInfo(changeDetails);
final Optional<GitRemote> remote = gerritGitUtil.getRemoteForChange(project, repository, firstFetchInfo);
if (!remote.isPresent()) {
Expand All @@ -100,21 +105,33 @@ public Void call() throws Exception {
validName = newBranchNameValidator.checkInput(checkedOutBranchName);
i++;
}
brancher.checkoutNewBranchStartingFrom(checkedOutBranchName, "FETCH_HEAD", gitRepositories, new Runnable() {
final String finalCheckedOutBranchName = checkedOutBranchName;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
try {
gerritGitUtil.setUpstreamBranch(repository, remote.get().getName() + "/" + changeDetails.branch);
} catch (VcsException e) {
NotificationBuilder builder = new NotificationBuilder(project, "Checkout Error", e.getMessage());
notificationService.notifyError(builder);
}
brancher.checkoutNewBranchStartingFrom(finalCheckedOutBranchName, "FETCH_HEAD", gitRepositories, new Runnable() {
@Override
public void run() {
GitVcs.runInBackground(new Task.Backgroundable(project, "Setting upstream branch...", false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
gerritGitUtil.setUpstreamBranch(repository, remote.get().getName() + "/" + changeDetails.branch);
} catch (VcsException e) {
NotificationBuilder builder = new NotificationBuilder(project, "Checkout Error", e.getMessage());
notificationService.notifyError(builder);
}
}
});
}
});
}
});
}
);
return null;
}
};
fetchAction.fetchChange(selectedChange.get(), project, successCallable);
fetchAction.fetchChange(selectedChange.get(), project, fetchCallback);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.inject.Inject;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.util.Consumer;
import com.urswolfer.intellij.plugin.gerrit.GerritModule;
Expand Down Expand Up @@ -57,14 +58,19 @@ public void actionPerformed(final AnActionEvent anActionEvent) {
getChangeDetail(selectedChange.get(), project, new Consumer<ChangeInfo>() {
@Override
public void consume(final ChangeInfo changeInfo) {
Callable<Void> successCallable = new Callable<Void>() {
Callable<Void> fetchCallback = new Callable<Void>() {
@Override
public Void call() throws Exception {
gerritGitUtil.cherryPickChange(project, changeInfo, selectedRevisions.get(changeInfo));
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
gerritGitUtil.cherryPickChange(project, changeInfo, selectedRevisions.get(changeInfo));
}
});
return null;
}
};
fetchAction.fetchChange(selectedChange.get(), project, successCallable);
fetchAction.fetchChange(selectedChange.get(), project, fetchCallback);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.urswolfer.intellij.plugin.gerrit.GerritModule;
import com.urswolfer.intellij.plugin.gerrit.git.GerritGitUtil;
Expand Down Expand Up @@ -68,15 +69,15 @@ public Void call() throws Exception {
fetchAction.fetchChange(selectedChange.get(), project, successCallable);
}

private void diffChange(Project project, ChangeInfo changeInfo) {
private void diffChange(final Project project, ChangeInfo changeInfo) {
Optional<GitRepository> gitRepositoryOptional = gerritGitUtil.getRepositoryForGerritProject(project, changeInfo.project);
if (!gitRepositoryOptional.isPresent()) {
NotificationBuilder notification = new NotificationBuilder(project, "Error",
String.format("No repository found for Gerrit project: '%s'.", changeInfo.project));
notificationService.notifyError(notification);
return;
}
GitRepository gitRepository = gitRepositoryOptional.get();
final GitRepository gitRepository = gitRepositoryOptional.get();

final String branchName = "FETCH_HEAD";
GitLocalBranch currentBranch = gitRepository.getCurrentBranch();
Expand All @@ -88,9 +89,14 @@ private void diffChange(Project project, ChangeInfo changeInfo) {
}
assert currentBranchName != null : "Current branch is neither a named branch nor a revision";

GitCommitCompareInfo compareInfo = gerritGitUtil.loadCommitsToCompare(
final GitCommitCompareInfo compareInfo = gerritGitUtil.loadCommitsToCompare(
Collections.singletonList(gitRepository), branchName, project);
new GitCompareBranchesDialog(project, branchName, currentBranchName, compareInfo, gitRepository).show();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
new GitCompareBranchesDialog(project, branchName, currentBranchName, compareInfo, gitRepository).show();
}
});
}

public static class Proxy extends CompareBranchAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class FetchAction {
@Inject
private SelectedRevisions selectedRevisions;

public void fetchChange(ChangeInfo selectedChange, final Project project, final Callable<Void> successCallable) {
public void fetchChange(ChangeInfo selectedChange, final Project project, final Callable<Void> fetchCallback) {
gerritUtil.getChangeDetails(selectedChange._number, project, new Consumer<ChangeInfo>() {
@Override
public void consume(ChangeInfo changeDetails) {
Expand All @@ -63,7 +63,7 @@ public void consume(ChangeInfo changeDetails) {
if (firstFetchInfo == null) {
return;
}
gerritGitUtil.fetchChange(project, gitRepository.get(), firstFetchInfo, commitHash, successCallable);
gerritGitUtil.fetchChange(project, gitRepository.get(), firstFetchInfo, commitHash, fetchCallback);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
import com.intellij.openapi.ui.popup.JBPopupListener;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.util.Consumer;
import com.urswolfer.intellij.plugin.gerrit.GerritSettings;
Expand Down Expand Up @@ -108,7 +108,10 @@ private void addVersionedComment(final Project project) {

final CommentForm commentForm = new CommentForm(project, editor, filePath, commentSide, commentToEdit);
final JBPopup balloon = commentBalloonBuilder.getNewCommentBalloon(commentForm, "Comment");
balloon.addListener(new JBPopupAdapter() {
balloon.addListener(new JBPopupListener() {
@Override
public void beforeShown(LightweightWindowEvent lightweightWindowEvent) {}

@Override
public void onClosed(LightweightWindowEvent event) {
DraftInput comment = commentForm.getComment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.ComponentPopupBuilder;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupAdapter;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.JBPopupListener;
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.Consumer;
Expand Down Expand Up @@ -119,7 +119,10 @@ public void actionPerformed(AnActionEvent e) {
popup.showInScreenCoordinates(getFilterValueLabel(), point);
final JComponent content = popup.getContent();
selectOkAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content);
popup.addListener(new JBPopupAdapter() {
popup.addListener(new JBPopupListener() {
@Override
public void beforeShown(LightweightWindowEvent lightweightWindowEvent) {}

@Override
public void onClosed(LightweightWindowEvent event) {
selectOkAction.unregisterCustomShortcutSet(content);
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
href="https://github.com/uwolfer/gerrit-intellij-plugin#pre-releases">
https://github.com/uwolfer/gerrit-intellij-plugin#pre-releases</a>.</li>
<li>1.2.4</li>
<ul>
<li>fix assertion error in logs when running some Git operations</li>
<li>minor fixes and improvements</li>
</ul>
<li>1.2.3</li>
<ul>
<li>add support displaying "reviewed" status in file tree (thanks to Leonard Brünings)</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
import com.google.common.base.Suppliers;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.intellij.diff.DiffManager;
import com.intellij.ide.DataManager;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.diff.DiffManager;
import com.intellij.openapi.options.ShowSettingsUtil;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.vfs.LocalFileSystem;
Expand Down Expand Up @@ -61,7 +60,6 @@ protected void installOpenIdeDependenciesModule() {
bindMock(LocalFileSystem.class);

bindMock(Git.class);
bindMock(FileDocumentManager.class);
bindMock(VirtualFileManager.class);

bindMock(ShowSettingsUtil.class);
Expand Down

0 comments on commit 1e4aeb0

Please sign in to comment.