Merge branch 'stable-3.1'
* stable-3.1:
Upgrade bazlets to latest stable-3.1 to build with 3.1.7 API
Upgrade bazlets to latest stable-3.0 to build with 3.0.11 API
Remove the commented-out snapshot plugin api lines
Adapt SNAPSHOT plugin api example to the 3.1 version
Upgrade bazlets to latest stable-3.1
Prepare for new gerrit_api snapshot version usage
Upgrade bazlets to latest stable-3.0
Upgrade bazlets to latest stable-3.0
Change-Id: I098d8e9395e825c4b7abbf94a1d2af0b130708fa
diff --git a/WORKSPACE b/WORKSPACE
index 55ae3e1..459692a 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "b6cb89690a5e06261932eb30c95fd8db34a7943a",
+ commit = "53cfe52b1b691040fd03dfe025c0a381df48c6ee",
#local_path = "/home/<user>/projects/bazlets",
)
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());