Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/intellij14' into intellij14.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
#	src/main/java/com/urswolfer/intellij/plugin/gerrit/ui/GerritToolWindow.java
  • Loading branch information
uwolfer committed Jun 28, 2017
2 parents ce22bb0 + c513c5f commit 6d52293
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 78 deletions.
47 changes: 19 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ gerrit-intellij-plugin
Introduction
-----------

Unofficial [IntelliJ Platform] plugin for the [Gerrit Code Review] tool. It supports any product based on the IntelliJ platform:
Unofficial [IntelliJ Platform](http://www.jetbrains.com/idea/) plugin for the
[Gerrit Code Review](https://www.gerritcodereview.com/) tool. It supports any product based on the IntelliJ platform:
* IntelliJ IDEA
* IntelliJ IDEA CE
* RubyMine
Expand All @@ -16,18 +17,15 @@ Unofficial [IntelliJ Platform] plugin for the [Gerrit Code Review] tool. It supp
* PyCharm CE
* AppCode
* Android Studio
* 0xDBE
* DataGrip
* CLion
* Gogland
* Rider

Only Gerrit 2.6 or newer is supported (missing / incomplete REST API in older versions).

[IntelliJ Platform]: http://www.jetbrains.com/idea/
[Gerrit Code Review]: https://www.gerritcodereview.com/

You can install this plugin from the [IntelliJ Plugin Manager].
You can install this plugin from the [IntelliJ Plugin Manager](http://plugins.jetbrains.com/plugin/7272).
If you install this plugin directly in your IDE's plugin manager, you will get notified when a new release is available.
[IntelliJ Plugin Manager]: http://plugins.jetbrains.com/plugin/7272

###### Pre-Releases
If you want to get new releases earlier, you can subscribe to the release-candidate plugin channel:
Expand All @@ -41,12 +39,10 @@ Your Support
------------
If you like this plugin, you can support it:
* Spread it: Tell your friends who are using IntelliJ and Gerrit about this plugin (or even encourage them to use these fantastic products!)
* Vote for it: Write your review and vote for it at the [IntelliJ plugin repository].
* Star it: [Star it at GitHub]. GitHub account required.
* Vote for it: Write your review and vote for it at the [IntelliJ plugin repository](http://plugins.jetbrains.com/plugin/7272).
* Star it: [Star it at GitHub](https://github.com/uwolfer/gerrit-intellij-plugin). GitHub account required.
* Improve it: Report bugs or feature requests. Or even fix / implement them by yourself - everything is open source!
* Donate: You can find donation-possibilities at the bottom of this file.
[IntelliJ plugin repository]: http://plugins.jetbrains.com/plugin/7272
[Star it at GitHub]: https://github.com/uwolfer/gerrit-intellij-plugin

Troubleshooting
---------------
Expand Down Expand Up @@ -78,32 +74,27 @@ error or checking out does not properly finish, you can try to:
* use SSH clone URL in checkout dialog (you can find the SSH URL in the Gerrit Web UI project settings)
* or: check out with the default Git plugin and set up the Gerrit plugin manually afterwards

You can find background information about this issue in a [Gerrit mailing list topic].
[Gerrit mailing list topic]: https://groups.google.com/forum/#!topic/repo-discuss/UnQd3HsL820
You can find background information about this issue in a [Gerrit mailing list topic](https://groups.google.com/forum/#!topic/repo-discuss/UnQd3HsL820).

### Loading file-diff-list is slow
Diff viewing is based on Git operations (i.e. it fetches the commit from the Gerrit remote). When loading the file list
takes a lot of time, you can run a local "[git gc]" and ask your Gerrit administrator to do run a "[gerrit gc]".
[git gc]: https://www.kernel.org/pub/software/scm/git/docs/git-gc.html
[gerrit gc]: https://gerrit-review.googlesource.com/Documentation/cmd-gc.html
takes a lot of time, you can run a local "[git gc](https://www.kernel.org/pub/software/scm/git/docs/git-gc.html)"
and ask your Gerrit administrator to do run a "[gerrit gc](https://gerrit-review.googlesource.com/Documentation/cmd-gc.html)".

Architecture
------------
### IntelliJ Integration
The plugin is integrated into the IntelliJ IDE with a [tool window].
[tool window]: http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Tool+Windows
The plugin is integrated into the IntelliJ IDE with a [tool window](http://confluence.jetbrains.com/display/IDEADEV/IntelliJ+IDEA+Tool+Windows).
See package <code>com.urswolfer.intellij.plugin.gerrit.ui</code>.

### REST API
Most of the communication between the plugin and a Gerrit instance is based on the [Gerrit REST API].
The REST specific part is available as [standalone implementation].
[Gerrit REST API]: https://gerrit-review.googlesource.com/Documentation/rest-api.html
[standalone implementation]: https://github.com/uwolfer/gerrit-rest-java-client
Most of the communication between the plugin and a Gerrit instance is based on the [Gerrit REST API](https://gerrit-review.googlesource.com/Documentation/rest-api.html).
The REST specific part is available as [standalone implementation](https://github.com/uwolfer/gerrit-rest-java-client).
See package <code>com.urswolfer.intellij.plugin.gerrit.rest</code>.

### Git
Some actions like comparing and listing files are based on Git operations. [IntelliJ Git4Idea] is used for these operations.
[IntelliJ Git4Idea]:http://git.jetbrains.org/?p=idea/community.git;a=tree;f=plugins/git4idea
Some actions like comparing and listing files are based on Git operations.
[IntelliJ Git4Idea](http://git.jetbrains.org/?p=idea/community.git;a=tree;f=plugins/git4idea) is used for these operations.
See package <code>com.urswolfer.intellij.plugin.gerrit.git</code>.


Expand All @@ -115,7 +106,7 @@ It's very easy to set it up as an IntelliJ project.
1. Activate plugins ```Gradle```, ```Plugin DevKit``` and ```UI Designer``` in IntelliJ.
2. ```git clone https://github.com/uwolfer/gerrit-intellij-plugin``` (probably switch to ```intellij{version}``` branch, but keep in mind that pull-requests should be against the default branch ("intellij13" and older are not supported anymore))
3. Open checked out project in IntelliJ ("File" -> "New" -> "Project from Existing Sources" -> select file ```build.gradle``` in ```gerrit-intellij-plugin``` folder and press "OK")
4. Create a new run configuration: "Gradle" -> "Gradle project": select the only project -> "Tasks": "runIdea"
4. Create a new run configuration: "Gradle" -> "Gradle project": select the only project -> "Tasks": "runIde"
5. Press "Debug" button. IntelliJ should start with a clean workspace (development sandbox). You need to checkout a
project to see changes (it shows only changes for Git repositories that are set up in current workspace by default).

Expand All @@ -129,10 +120,10 @@ Credits

Donations
--------
If you like this work, you can support it with [this donation link]. If you don't like Paypal
(Paypal takes 2.9% plus $0.30 per transaction fee from your donation), please contact me.
If you like this work, you can support it with
[this donation link](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=8F2GZVBCVEDUQ).
If you don't like Paypal (Paypal takes 2.9% plus $0.30 per transaction fee from your donation), please contact me.
Please only use the link from github.com/uwolfer/gerrit-intellij-plugin to verify that it is correct.
[this donation link]: https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=8F2GZVBCVEDUQ


Copyright and license
Expand Down
18 changes: 9 additions & 9 deletions 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.1.10'
id 'org.jetbrains.intellij' version '0.2.9'
}

apply plugin: 'java'
Expand All @@ -41,22 +41,22 @@ repositories {
}

dependencies {
compile ('com.google.inject:guice:4.0') {
compile ('com.google.inject:guice:4.1') {
exclude group: 'com.google.guava', module: 'guava'
}
compile ('com.google.inject.extensions:guice-multibindings:4.0') {
compile ('com.google.inject.extensions:guice-multibindings:4.1.0') {
exclude group: 'com.google.guava', module: 'guava'
}
compile ('com.urswolfer.gerrit.client.rest:gerrit-rest-java-client:0.8.8') {
compile ('com.urswolfer.gerrit.client.rest:gerrit-rest-java-client:0.8.12') {
exclude group: 'com.google.code.gson', module: 'gson'
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
compile 'org.javassist:javassist:3.19.0-GA'
compile 'org.javassist:javassist:3.21.0-GA'

testCompile 'org.testng:testng:6.8.7'
testCompile 'org.easymock:easymock:3.2'
testCompile 'org.testng:testng:6.8.21'
testCompile 'org.easymock:easymock:3.4'
}

intellij {
Expand All @@ -66,8 +66,8 @@ intellij {
downloadSources Boolean.valueOf(downloadIdeaSources)
plugins 'git4idea'

publish {
channel ijPluginRepoChannel
publishPlugin {
channels ijPluginRepoChannel
username System.getenv('IJ_REPO_USERNAME')
password System.getenv('IJ_REPO_PASSWORD')
}
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-14.1.6
ijPluginRepoChannel=
downloadIdeaSources=false
version=0.9.9.1-141
version=1.0.0.1-141
javaVersion=1.6
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.urswolfer.gerrit.client.rest.GerritAuthData;
import com.urswolfer.intellij.plugin.gerrit.ui.ShowProjectColumn;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;

/**
* Parts based on org.jetbrains.plugins.github.GithubSettings
*
Expand All @@ -59,6 +57,8 @@ public class GerritSettings implements PersistentStateComponent<Element>, Gerrit
private static final String PUSH_TO_GERRIT = "PushToGerrit";
private static final String SHOW_CHANGE_NUMBER_COLUMN = "ShowChangeNumberColumn";
private static final String SHOW_CHANGE_ID_COLUMN = "ShowChangeIdColumn";
private static final String SHOW_TOPIC_COLUMN = "ShowTopicColumn";
private static final String SHOW_PROJECT_COLUMN = "ShowProjectColumn";
private static final String GERRIT_SETTINGS_PASSWORD_KEY = "GERRIT_SETTINGS_PASSWORD_KEY";

private String login;
Expand All @@ -70,6 +70,8 @@ public class GerritSettings implements PersistentStateComponent<Element>, Gerrit
private boolean pushToGerrit;
private boolean showChangeNumberColumn;
private boolean showChangeIdColumn;
private boolean showTopicColumn;
private ShowProjectColumn showProjectColumn = ShowProjectColumn.AUTO;

private Logger log;

Expand All @@ -84,6 +86,8 @@ public Element getState() {
element.setAttribute(PUSH_TO_GERRIT, Boolean.toString(getPushToGerrit()));
element.setAttribute(SHOW_CHANGE_NUMBER_COLUMN, Boolean.toString(getShowChangeNumberColumn()));
element.setAttribute(SHOW_CHANGE_ID_COLUMN, Boolean.toString(getShowChangeIdColumn()));
element.setAttribute(SHOW_TOPIC_COLUMN, Boolean.toString(getShowTopicColumn()));
element.setAttribute(SHOW_PROJECT_COLUMN, getShowProjectColumn().name());
return element;
}

Expand All @@ -100,6 +104,8 @@ public void loadState(@NotNull final Element element) {
setPushToGerrit(getBooleanValue(element, PUSH_TO_GERRIT));
setShowChangeNumberColumn(getBooleanValue(element, SHOW_CHANGE_NUMBER_COLUMN));
setShowChangeIdColumn(getBooleanValue(element, SHOW_CHANGE_ID_COLUMN));
setShowTopicColumn(getBooleanValue(element, SHOW_TOPIC_COLUMN));
setShowProjectColumn(getShowProjectColumnValue(element, SHOW_PROJECT_COLUMN));
} catch (Exception e) {
log.error("Error happened while loading gerrit settings: " + e);
}
Expand All @@ -123,6 +129,15 @@ private int getIntegerValue(Element element, String attributeName) {
}
}

private ShowProjectColumn getShowProjectColumnValue(Element element, String attributeName) {
String attributeValue = element.getAttributeValue(attributeName);
if (attributeValue != null) {
return ShowProjectColumn.valueOf(attributeValue);
} else {
return ShowProjectColumn.AUTO;
}
}

@Override
@Nullable
public String getLogin() {
Expand All @@ -142,6 +157,11 @@ public String getPassword() {
return StringUtil.notNullize(password);
}

@Override
public boolean isHttpPassword() {
return false;
}

@Override
public String getHost() {
return host;
Expand Down Expand Up @@ -232,6 +252,22 @@ public void setShowChangeIdColumn(boolean showChangeIdColumn) {
this.showChangeIdColumn = showChangeIdColumn;
}

public boolean getShowTopicColumn() {
return showTopicColumn;
}

public ShowProjectColumn getShowProjectColumn() {
return showProjectColumn;
}

public void setShowProjectColumn(ShowProjectColumn showProjectColumn) {
this.showProjectColumn = showProjectColumn;
}

public void setShowTopicColumn(boolean showTopicColumn) {
this.showTopicColumn = showTopicColumn;
}

public void setLog(Logger log) {
this.log = log;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String get(ChangeInfo changeInfo) {
currentRevision = Iterables.getLast(revisionKeys);
}
}
return get(changeInfo.id).or(currentRevision);
return get(changeInfo.id).or(Optional.fromNullable(currentRevision)).orNull();
}

public void put(String changeId, String revisionHash) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ public Optional<GitRepository> getRepositoryForGerritProject(Project project, St
}
}
}
NotificationBuilder notification = new NotificationBuilder(project, "Error",
String.format("No repository found for Gerrit project: '%s'.", gerritProjectName));
notificationService.notifyError(notification);
return Optional.absent();
}

Expand Down Expand Up @@ -162,7 +159,12 @@ public void cherryPickChange(final Project project, final ChangeInfo changeInfo,
public void run(@NotNull ProgressIndicator indicator) {
try {
Optional<GitRepository> gitRepositoryOptional = getRepositoryForGerritProject(project, changeInfo.project);
if (!gitRepositoryOptional.isPresent()) return;
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 VirtualFile virtualFile = gitRepository.getGitDir();
Expand Down
Loading

0 comments on commit 6d52293

Please sign in to comment.