Merge "Allow ExternalIncludedIn extensions to add multiple Included In rows"
*submodules: * Update plugins/cookbook-plugin from branch 'master' - Add example implementation of ExternalIncludedIn extension point Change-Id: Ied5517cf9da58c748ad60bdf96444828a6051df3 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -27,6 +27,7 @@ java_library(
|
|||||||
name = 'lib',
|
name = 'lib',
|
||||||
exported_deps = [
|
exported_deps = [
|
||||||
':api',
|
':api',
|
||||||
|
'//lib:guava',
|
||||||
'//lib/guice:guice',
|
'//lib/guice:guice',
|
||||||
'//lib/guice:guice-assistedinject',
|
'//lib/guice:guice-assistedinject',
|
||||||
'//lib/guice:guice-servlet',
|
'//lib/guice:guice-servlet',
|
||||||
@@ -42,6 +43,7 @@ java_library(
|
|||||||
'//gerrit-common:annotations',
|
'//gerrit-common:annotations',
|
||||||
],
|
],
|
||||||
provided_deps = [
|
provided_deps = [
|
||||||
|
'//lib:guava',
|
||||||
'//lib/guice:guice',
|
'//lib/guice:guice',
|
||||||
'//lib/guice:guice-assistedinject',
|
'//lib/guice:guice-assistedinject',
|
||||||
],
|
],
|
||||||
|
@@ -23,6 +23,7 @@ java_library(
|
|||||||
name = 'lib',
|
name = 'lib',
|
||||||
exports = [
|
exports = [
|
||||||
':api',
|
':api',
|
||||||
|
'//lib:guava',
|
||||||
'//lib/guice:guice',
|
'//lib/guice:guice',
|
||||||
'//lib/guice:guice-assistedinject',
|
'//lib/guice:guice-assistedinject',
|
||||||
'//lib/guice:guice-servlet',
|
'//lib/guice:guice-servlet',
|
||||||
@@ -37,6 +38,7 @@ java_library(
|
|||||||
srcs = glob([SRC + '**/*.java']),
|
srcs = glob([SRC + '**/*.java']),
|
||||||
deps = [
|
deps = [
|
||||||
'//gerrit-common:annotations',
|
'//gerrit-common:annotations',
|
||||||
|
'//lib:guava',
|
||||||
'//lib/guice:guice',
|
'//lib/guice:guice',
|
||||||
'//lib/guice:guice-assistedinject',
|
'//lib/guice:guice-assistedinject',
|
||||||
],
|
],
|
||||||
|
@@ -14,16 +14,18 @@
|
|||||||
|
|
||||||
package com.google.gerrit.extensions.config;
|
package com.google.gerrit.extensions.config;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@ExtensionPoint
|
@ExtensionPoint
|
||||||
public interface ExternalIncludedIn {
|
public interface ExternalIncludedIn {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of systems that include the given commit.
|
* Returns additional entries for IncludedInInfo as multimap where the
|
||||||
|
* key is the row title and the the values are a list of systems that include
|
||||||
|
* the given commit (e.g. names of servers on which this commit is deployed).
|
||||||
*
|
*
|
||||||
* The tags and branches in which the commit is included are provided so that
|
* The tags and branches in which the commit is included are provided so that
|
||||||
* a RevWalk can be avoided when a system runs a certain tag or branch.
|
* a RevWalk can be avoided when a system runs a certain tag or branch.
|
||||||
@@ -33,9 +35,8 @@ public interface ExternalIncludedIn {
|
|||||||
* included
|
* included
|
||||||
* @param tags the tags that include the commit
|
* @param tags the tags that include the commit
|
||||||
* @param branches the branches that include the commit
|
* @param branches the branches that include the commit
|
||||||
* @return a list of systems that contain the given commit, e.g. names of
|
* @return additional entries for IncludedInInfo
|
||||||
* servers on which this commit is deployed
|
|
||||||
*/
|
*/
|
||||||
List<String> getIncludedIn(String project, String commit,
|
Multimap<String, String> getIncludedIn(String project, String commit,
|
||||||
Collection<String> tags, Collection<String> branches);
|
Collection<String> tags, Collection<String> branches);
|
||||||
}
|
}
|
||||||
|
@@ -14,8 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.gerrit.extensions.config.ExternalIncludedIn;
|
import com.google.gerrit.extensions.config.ExternalIncludedIn;
|
||||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
@@ -39,7 +41,6 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -48,13 +49,13 @@ class IncludedIn implements RestReadView<ChangeResource> {
|
|||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final PatchSetUtil psUtil;
|
private final PatchSetUtil psUtil;
|
||||||
private final DynamicMap<ExternalIncludedIn> includedIn;
|
private final DynamicSet<ExternalIncludedIn> includedIn;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
IncludedIn(Provider<ReviewDb> db,
|
IncludedIn(Provider<ReviewDb> db,
|
||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
PatchSetUtil psUtil,
|
PatchSetUtil psUtil,
|
||||||
DynamicMap<ExternalIncludedIn> includedIn) {
|
DynamicSet<ExternalIncludedIn> includedIn) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.psUtil = psUtil;
|
this.psUtil = psUtil;
|
||||||
@@ -80,13 +81,13 @@ class IncludedIn implements RestReadView<ChangeResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
|
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
|
||||||
Map<String, Collection<String>> external = new HashMap<>();
|
Multimap<String, String> external = ArrayListMultimap.create();
|
||||||
for (DynamicMap.Entry<ExternalIncludedIn> i : includedIn) {
|
for (ExternalIncludedIn ext : includedIn) {
|
||||||
external.put(i.getExportName(),
|
external.putAll(ext.getIncludedIn(project.get(), rev.name(),
|
||||||
i.getProvider().get().getIncludedIn(
|
d.getTags(), d.getBranches()));
|
||||||
project.get(), rev.name(), d.getTags(), d.getBranches()));
|
|
||||||
}
|
}
|
||||||
return new IncludedInInfo(d, (!external.isEmpty() ? external : null));
|
return new IncludedInInfo(d,
|
||||||
|
(!external.isEmpty() ? external.asMap() : null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -342,7 +342,7 @@ public class GerritGlobalModule extends FactoryModule {
|
|||||||
DynamicMap.mapOf(binder(), DownloadScheme.class);
|
DynamicMap.mapOf(binder(), DownloadScheme.class);
|
||||||
DynamicMap.mapOf(binder(), DownloadCommand.class);
|
DynamicMap.mapOf(binder(), DownloadCommand.class);
|
||||||
DynamicMap.mapOf(binder(), CloneCommand.class);
|
DynamicMap.mapOf(binder(), CloneCommand.class);
|
||||||
DynamicMap.mapOf(binder(), ExternalIncludedIn.class);
|
DynamicSet.setOf(binder(), ExternalIncludedIn.class);
|
||||||
DynamicMap.mapOf(binder(), ProjectConfigEntry.class);
|
DynamicMap.mapOf(binder(), ProjectConfigEntry.class);
|
||||||
DynamicSet.setOf(binder(), PatchSetWebLink.class);
|
DynamicSet.setOf(binder(), PatchSetWebLink.class);
|
||||||
DynamicSet.setOf(binder(), FileWebLink.class);
|
DynamicSet.setOf(binder(), FileWebLink.class);
|
||||||
|
Submodule plugins/cookbook-plugin updated: 69b8f9f413...d7d303c48f
Reference in New Issue
Block a user