Merge branch 'stable-3.1'
* stable-3.1:
Upgrade bazlets to latest stable-3.1
Change-Id: I94b365f3137aaa626833eac6f47386e250555e26
diff --git a/WORKSPACE b/WORKSPACE
index 0a39e38..c856738 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,27 +3,27 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "65536a2b01b0097ee3237bb48a805ed97ca51467",
+ commit = "f30a992da9fc855dce819875afb59f9dd6f860cd",
#local_path = "/home/<user>/projects/bazlets",
)
# Snapshot Plugin API
-#load(
-# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-# "gerrit_api_maven_local",
-#)
-
-# Load snapshot Plugin API
-#gerrit_api_maven_local()
-
-# Release Plugin API
load(
- "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
- "gerrit_api",
+ "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+ "gerrit_api_maven_local",
)
+# Load snapshot Plugin API
+gerrit_api_maven_local()
+
+# Release Plugin API
+#load(
+# "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+# "gerrit_api",
+#)
+
# Load release Plugin API
-gerrit_api()
+#gerrit_api()
load("//:external_plugin_deps.bzl", "external_plugin_deps")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
index 3625e9a..ef251db 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
@@ -32,6 +32,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
+import java.util.NoSuchElementException;
import org.kohsuke.args4j.Argument;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,7 +67,7 @@
input.name = newProjectName;
ProjectResource rsrc =
new ProjectResource(
- projectCacheProvider.get().get(Project.nameKey(projectControl)), self.get());
+ projectCacheProvider.get().get(Project.nameKey(projectControl)).get(), self.get());
try (CommandProgressMonitor monitor = new CommandProgressMonitor(stdout)) {
renameProject.assertCanRename(rsrc, input, monitor);
List<Change.Id> changeIds = renameProject.getChanges(rsrc, monitor);
@@ -79,7 +80,7 @@
stdout.flush();
}
}
- } catch (RestApiException | IOException e) {
+ } catch (NoSuchElementException | RestApiException | IOException e) {
throw die(e);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
index 204c564..cab2957 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
@@ -25,7 +25,7 @@
import com.google.gerrit.server.project.ProjectResource;
import com.google.gerrit.server.restapi.project.ListChildProjects;
import com.google.gerrit.server.submit.MergeOpRepoManager;
-import com.google.gerrit.server.submit.SubmoduleException;
+import com.google.gerrit.server.submit.SubmoduleConflictException;
import com.google.gerrit.server.submit.SubmoduleOp;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -121,7 +121,7 @@
throw new CannotRenameProjectException(message);
}
}
- } catch (IOException | SubmoduleException e) {
+ } catch (IOException | SubmoduleConflictException e) {
throw new CannotRenameProjectException(e);
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProjectTest.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProjectTest.java
index aa3776f..02c47c5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProjectTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProjectTest.java
@@ -34,10 +34,13 @@
@Test
public void testLockUnlockSucceeds() throws IOException, ConfigInvalidException {
- assertThat(projectCache.get(project).getProject().getState()).isEqualTo(ProjectState.ACTIVE);
+ assertThat(projectCache.get(project).get().getProject().getState())
+ .isEqualTo(ProjectState.ACTIVE);
lockUnlockInstance.lock(project);
- assertThat(projectCache.get(project).getProject().getState()).isEqualTo(ProjectState.READ_ONLY);
+ assertThat(projectCache.get(project).get().getProject().getState())
+ .isEqualTo(ProjectState.READ_ONLY);
lockUnlockInstance.unlock(project);
- assertThat(projectCache.get(project).getProject().getState()).isEqualTo(ProjectState.ACTIVE);
+ assertThat(projectCache.get(project).get().getProject().getState())
+ .isEqualTo(ProjectState.ACTIVE);
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
index 41bd819..6a450e9 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
@@ -29,6 +29,7 @@
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.List;
+import java.util.Optional;
import javax.inject.Named;
import org.eclipse.jgit.junit.TestRepository;
import org.junit.Test;
@@ -55,8 +56,8 @@
adminSshSession.exec(PLUGIN_NAME + " " + project.get() + " " + NEW_PROJECT_NAME);
adminSshSession.assertSuccess();
- ProjectState projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
- assertThat(projectState).isNotNull();
+ Optional<ProjectState> projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
+ assertThat(projectState.isPresent()).isTrue();
assertThat(queryProvider.get().byProject(project)).isEmpty();
assertThat(queryProvider.get().byProject(Project.nameKey(NEW_PROJECT_NAME))).isNotEmpty();
}
@@ -69,8 +70,8 @@
adminSshSession.exec(PLUGIN_NAME + " " + project.get() + " " + newProjectName);
adminSshSession.assertFailure();
- ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
- assertThat(projectState).isNull();
+ Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
+ assertThat(projectState.isPresent()).isFalse();
}
@Test
@@ -80,8 +81,8 @@
adminSshSession.exec(PLUGIN_NAME + " " + allProjects.get() + " " + NEW_PROJECT_NAME);
adminSshSession.assertFailure();
- ProjectState projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
- assertThat(projectState).isNull();
+ Optional<ProjectState> projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
+ assertThat(projectState.isPresent()).isFalse();
}
@Test
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
index c13f2e6..b895bfa 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
@@ -30,6 +30,7 @@
import com.googlesource.gerrit.plugins.renameproject.RenameProject.Step;
import com.googlesource.gerrit.plugins.renameproject.monitor.ProgressMonitor;
import java.util.List;
+import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -125,22 +126,22 @@
}
private void assertReverted() throws Exception {
- ProjectState oldProjectState = projectCache.get(oldProjectKey);
- assertThat(oldProjectState).isNotNull();
+ Optional<ProjectState> oldProjectState = projectCache.get(oldProjectKey);
+ assertThat(oldProjectState.isPresent()).isTrue();
- ProjectState newProjectState = projectCache.get(newProjectKey);
- assertThat(newProjectState).isNull();
+ Optional<ProjectState> newProjectState = projectCache.get(newProjectKey);
+ assertThat(newProjectState.isPresent()).isFalse();
assertThat(queryProvider.get().byProject(oldProjectKey)).isNotEmpty();
assertThat(queryProvider.get().byProject(newProjectKey)).isEmpty();
}
private void assertRenamed(Result result) throws Exception {
- ProjectState oldProjectState = projectCache.get(oldProjectKey);
- assertThat(oldProjectState).isNull();
+ Optional<ProjectState> oldProjectState = projectCache.get(oldProjectKey);
+ assertThat(oldProjectState.isPresent()).isFalse();
- ProjectState newProjectState = projectCache.get(newProjectKey);
- assertThat(newProjectState).isNotNull();
+ Optional<ProjectState> newProjectState = projectCache.get(newProjectKey);
+ assertThat(newProjectState.isPresent()).isTrue();
if (renameProject.getStepsPerformed().contains(Step.DATABASE)) {
ChangeApi changeApi = gApi.changes().id(NEW_PROJECT_NAME, result.getChange().getId().get());