diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-17 18:09:17 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-02-17 18:12:50 +0900 |
commit | 7e6ca5e84fe802bca380a6d85886ed2f13ea503f (patch) | |
tree | b1694975537e709591cd0a20f1f29f6c6328c1df | |
parent | 0bb6804f3e36063b812a40e43688a9c929903c07 (diff) |
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
-rw-r--r-- | gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java index b0ac201b98..964235dbf4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/CreateProject.java @@ -35,6 +35,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Project; 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.group.GroupsCollection; 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 Provider<CurrentUser> currentUser; private final Provider<PutConfig> putConfig; + private final AllProjectsName allProjects; private final String name; @Inject CreateProject(PerformCreateProject.Factory performCreateProjectFactory, Provider<ProjectsCollection> projectsCollection, - Provider<GroupsCollection> groupsCollection, ProjectJson json, + Provider<GroupsCollection> groupsCollection, + ProjectJson json, DynamicSet<ProjectCreationValidationListener> projectCreationValidationListeners, ProjectControl.GenericFactory projectControlFactory, - Provider<CurrentUser> currentUser, Provider<PutConfig> putConfig, + Provider<CurrentUser> currentUser, + Provider<PutConfig> putConfig, + AllProjectsName allProjects, @Assisted String name) { this.createProjectFactory = performCreateProjectFactory; this.projectsCollection = projectsCollection; @@ -80,6 +85,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn this.projectControlFactory = projectControlFactory; this.currentUser = currentUser; this.putConfig = putConfig; + this.allProjects = allProjects; this.name = name; } @@ -97,9 +103,9 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn final CreateProjectArgs args = new CreateProjectArgs(); args.setProjectName(name); - if (!Strings.isNullOrEmpty(input.parent)) { - args.newParent = projectsCollection.get().parse(input.parent).getControl(); - } + String parentName = MoreObjects.firstNonNull( + Strings.emptyToNull(input.parent), allProjects.get()); + args.newParent = projectsCollection.get().parse(parentName).getControl(); args.createEmptyCommit = input.createEmptyCommit; args.permissionsOnly = input.permissionsOnly; args.projectDescription = Strings.emptyToNull(input.description); |