CreateProject: Explicitly set parent to All-Projects when not specified
When the parent is not specified, and the project's other settings are all default, no project.config file is created on refs/meta/config. This prevents metadata updates from working as expected when they result in a file being removed. Explicitly set the parent to All-Projects when not specified, so that a project.config file gets created on refs/meta/config. Bug: Issue 3919 Change-Id: I4c0a11253413ff0b6a75e87429949be90a15aa95
This commit is contained in:
@@ -35,6 +35,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
|||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
import com.google.gerrit.server.git.ProjectConfig;
|
||||||
import com.google.gerrit.server.group.GroupsCollection;
|
import com.google.gerrit.server.group.GroupsCollection;
|
||||||
import com.google.gerrit.server.validators.ProjectCreationValidationListener;
|
import com.google.gerrit.server.validators.ProjectCreationValidationListener;
|
||||||
@@ -62,15 +63,19 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
|||||||
private final ProjectControl.GenericFactory projectControlFactory;
|
private final ProjectControl.GenericFactory projectControlFactory;
|
||||||
private final Provider<CurrentUser> currentUser;
|
private final Provider<CurrentUser> currentUser;
|
||||||
private final Provider<PutConfig> putConfig;
|
private final Provider<PutConfig> putConfig;
|
||||||
|
private final AllProjectsName allProjects;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CreateProject(PerformCreateProject.Factory performCreateProjectFactory,
|
CreateProject(PerformCreateProject.Factory performCreateProjectFactory,
|
||||||
Provider<ProjectsCollection> projectsCollection,
|
Provider<ProjectsCollection> projectsCollection,
|
||||||
Provider<GroupsCollection> groupsCollection, ProjectJson json,
|
Provider<GroupsCollection> groupsCollection,
|
||||||
|
ProjectJson json,
|
||||||
DynamicSet<ProjectCreationValidationListener> projectCreationValidationListeners,
|
DynamicSet<ProjectCreationValidationListener> projectCreationValidationListeners,
|
||||||
ProjectControl.GenericFactory projectControlFactory,
|
ProjectControl.GenericFactory projectControlFactory,
|
||||||
Provider<CurrentUser> currentUser, Provider<PutConfig> putConfig,
|
Provider<CurrentUser> currentUser,
|
||||||
|
Provider<PutConfig> putConfig,
|
||||||
|
AllProjectsName allProjects,
|
||||||
@Assisted String name) {
|
@Assisted String name) {
|
||||||
this.createProjectFactory = performCreateProjectFactory;
|
this.createProjectFactory = performCreateProjectFactory;
|
||||||
this.projectsCollection = projectsCollection;
|
this.projectsCollection = projectsCollection;
|
||||||
@@ -80,6 +85,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
|||||||
this.projectControlFactory = projectControlFactory;
|
this.projectControlFactory = projectControlFactory;
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.putConfig = putConfig;
|
this.putConfig = putConfig;
|
||||||
|
this.allProjects = allProjects;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +103,9 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
|||||||
|
|
||||||
final CreateProjectArgs args = new CreateProjectArgs();
|
final CreateProjectArgs args = new CreateProjectArgs();
|
||||||
args.setProjectName(name);
|
args.setProjectName(name);
|
||||||
if (!Strings.isNullOrEmpty(input.parent)) {
|
String parentName = MoreObjects.firstNonNull(
|
||||||
args.newParent = projectsCollection.get().parse(input.parent).getControl();
|
Strings.emptyToNull(input.parent), allProjects.get());
|
||||||
}
|
args.newParent = projectsCollection.get().parse(parentName).getControl();
|
||||||
args.createEmptyCommit = input.createEmptyCommit;
|
args.createEmptyCommit = input.createEmptyCommit;
|
||||||
args.permissionsOnly = input.permissionsOnly;
|
args.permissionsOnly = input.permissionsOnly;
|
||||||
args.projectDescription = Strings.emptyToNull(input.description);
|
args.projectDescription = Strings.emptyToNull(input.description);
|
||||||
|
Reference in New Issue
Block a user