Merge branch 'stable-3.1' into stable-3.2
* stable-3.1:
Bump version to v3.1.4 to match Gerrit
Adopt new replication configuration structure
Bug: Issue 12866
Change-Id: If1ccf95f8e8877c209db7f1dee8745e73d2e616c
diff --git a/github-oauth/pom.xml b/github-oauth/pom.xml
index 1f58981..75d3a27 100644
--- a/github-oauth/pom.xml
+++ b/github-oauth/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.googlesource.gerrit.plugins.github</groupId>
<artifactId>github-parent</artifactId>
- <version>3.1.4</version>
+ <version>3.2.0-rc1</version>
</parent>
<artifactId>github-oauth</artifactId>
<name>Gerrit Code Review - GitHub OAuth login</name>
diff --git a/github-plugin/pom.xml b/github-plugin/pom.xml
index f642067..95e3195 100644
--- a/github-plugin/pom.xml
+++ b/github-plugin/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>github-parent</artifactId>
<groupId>com.googlesource.gerrit.plugins.github</groupId>
- <version>3.1.4</version>
+ <version>3.2.0-rc1</version>
</parent>
<artifactId>github-plugin</artifactId>
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
index 9b234f5..cb71e78 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
@@ -82,7 +82,7 @@
private final int jobIndex;
private final ExternalIds externalIds;
private PullRequestCreateChange createChange;
- private Project project;
+ private Optional<Project> project;
private GitJobStatus status;
private boolean cancelRequested;
private AccountImporter accountImporter;
@@ -114,11 +114,10 @@
this.externalIds = externalIds;
}
- private Project fetchGerritProject(
+ private Optional<Project> fetchGerritProject(
ProjectCache projectCache, String fetchOrganisation, String fetchRepoName) {
NameKey projectNameKey = Project.NameKey.parse(fetchOrganisation + "/" + fetchRepoName);
- ProjectState projectState = projectCache.get(projectNameKey);
- return projectState.getProject();
+ return projectCache.get(projectNameKey).map(ProjectState::getProject);
}
@Override
@@ -179,17 +178,19 @@
GitHubUser gitHubUser = GitHubUser.from(prUser, commitAuthor);
Account.Id pullRequestOwner = getOrRegisterAccount(gitHubUser);
- Id changeId =
- createChange.addCommitToChange(
- project,
- gitRepo,
- destinationBranch,
- pullRequestOwner,
- revCommit,
- getChangeMessage(pr),
- String.format(TOPIC_FORMAT, new Integer(pr.getNumber())));
- if (changeId != null) {
- prChanges.add(changeId);
+ if (project.isPresent()) {
+ Id changeId =
+ createChange.addCommitToChange(
+ project.get(),
+ gitRepo,
+ destinationBranch,
+ pullRequestOwner,
+ revCommit,
+ getChangeMessage(pr),
+ String.format(TOPIC_FORMAT, new Integer(pr.getNumber())));
+ if (changeId != null) {
+ prChanges.add(changeId);
+ }
}
}
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
index 318dc81..e2b8041 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
@@ -160,9 +160,6 @@
email,
fullName,
username);
-
- accountCache.evict(accountId);
- log.debug("Account cache evicted for {}", accountId);
} catch (Exception e) {
throw new ServletException(
"Cannot associate email '" + email + "' to current user '" + user + "'", e);
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
index bd069a8..2cf6170 100644
--- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
+++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
@@ -67,7 +67,7 @@
if (ghRepository.hasPushAccess() && ghRepository.hasPullAccess()) {
JsonObject repository = new JsonObject();
String projectName = organisation + "/" + ghRepository.getName();
- if (projects.get(Project.NameKey.parse(projectName)) == null) {
+ if (!projects.get(Project.NameKey.parse(projectName)).isPresent()) {
repository.add("name", new JsonPrimitive(ghRepository.getName()));
repository.add("organisation", new JsonPrimitive(organisation));
repository.add(
diff --git a/pom.xml b/pom.xml
index 1ed940e..7affb60 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.googlesource.gerrit.plugins.github</groupId>
<artifactId>github-parent</artifactId>
- <version>3.1.4</version>
+ <version>3.2.0-rc1</version>
<name>Gerrit Code Review - GitHub integration</name>
<url>http://www.gerritforge.com</url>
<packaging>pom</packaging>