use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class SetParentCommand method getChildrenForReparenting.
/**
* Returns the children of the specified parent project that should be reparented. The returned
* list of child projects does not contain projects that were specified to be excluded from
* reparenting.
*/
private List<Project.NameKey> getChildrenForReparenting(ProjectState parent) throws Exception {
final List<Project.NameKey> childProjects = new ArrayList<>();
final List<Project.NameKey> excluded = new ArrayList<>(excludedChildren.size());
for (ProjectState excludedChild : excludedChildren) {
excluded.add(excludedChild.getProject().getNameKey());
}
final List<Project.NameKey> automaticallyExcluded = new ArrayList<>(excludedChildren.size());
if (newParentKey != null) {
automaticallyExcluded.addAll(getAllParents(newParentKey));
}
for (ProjectInfo child : listChildProjects.apply(new ProjectResource(parent, user)).value()) {
final Project.NameKey childName = Project.nameKey(child.name);
if (!excluded.contains(childName)) {
if (!automaticallyExcluded.contains(childName)) {
childProjects.add(childName);
} else {
stdout.println("Automatically excluded '" + childName + "' " + "from reparenting because it is in the parent " + "line of the new parent '" + newParentKey + "'.");
}
}
}
return childProjects;
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class Index method apply.
@Override
public Response.Accepted apply(ProjectResource rsrc, IndexProjectInput input) throws Exception {
String response = "Project " + rsrc.getName() + " submitted for reindexing";
reindex(rsrc.getNameKey(), input.async);
if (Boolean.TRUE.equals(input.indexChildren)) {
for (ProjectInfo child : listChildProjectsProvider.get().withRecursive(true).apply(rsrc).value()) {
reindex(Project.nameKey(child.name), input.async);
}
response += " (indexing children recursively)";
}
return Response.accepted(response);
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ProjectIT method createProjectWithPluginConfigs.
@Test
public void createProjectWithPluginConfigs() throws Exception {
String name = name("foo");
ProjectInput input = new ProjectInput();
input.name = name;
input.description = "foo description";
input.pluginConfigValues = newPluginConfigValues();
ProjectInfo info = gApi.projects().create(input).get();
assertThat(info.description).isEqualTo(input.description);
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ProjectIT method getProjectThatHasLabelDefinitionWithDuplicateValues.
@Test
public void getProjectThatHasLabelDefinitionWithDuplicateValues() throws Exception {
// Update the definition of the Code-Review label so that it has the value "+1 LGTM" twice.
// This update bypasses all validation checks so that the duplicate label value doesn't get
// rejected.
projectOperations.project(allProjects).forInvalidation().addProjectConfigUpdater(cfg -> cfg.setStringList("label", LabelId.CODE_REVIEW, "value", ImmutableList.of("+1 LGTM", "1 LGTM", "0 No Value", "-1 Looks Bad"))).invalidate();
// Verify that project info can be retrieved and that the label value "+1 LGTM" appears only
// once.
ProjectInfo projectInfo = gApi.projects().name(allProjects.get()).get();
assertThat(projectInfo.labels.keySet()).containsExactly(LabelId.CODE_REVIEW);
assertThat(projectInfo.labels.get(LabelId.CODE_REVIEW).values).containsExactly("+1", "LGTM", " 0", "No Value", "-1", "Looks Bad");
}
use of com.google.gerrit.extensions.common.ProjectInfo in project gerrit by GerritCodeReview.
the class ParentProjectPredicate method predicates.
protected static ImmutableList<Predicate<ChangeData>> predicates(ProjectCache projectCache, ChildProjects childProjects, String value) {
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(value));
if (!projectState.isPresent()) {
return ImmutableList.of();
}
ImmutableList.Builder<Predicate<ChangeData>> r = ImmutableList.builder();
r.add(ChangePredicates.project(projectState.get().getNameKey()));
try {
for (ProjectInfo p : childProjects.list(projectState.get().getNameKey())) {
r.add(ChangePredicates.project(Project.nameKey(p.name)));
}
} catch (PermissionBackendException e) {
logger.atWarning().withCause(e).log("cannot check permissions to expand child projects");
}
return r.build();
}
Aggregations