Support to configure default submit type for newly created projects
Bug: issue 2257 Change-Id: If65a15c1f2928d26ffb2ab6fb12acbdc9b2cdda8 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
parent
23e1a2e824
commit
a79ea550cc
@ -115,8 +115,11 @@ Description values containing spaces should be quoted in single quotes
|
|||||||
* CHERRY_PICK: always cherry-pick the commit.
|
* CHERRY_PICK: always cherry-pick the commit.
|
||||||
|
|
||||||
+
|
+
|
||||||
Defaults to MERGE_IF_NECESSARY. For more details see
|
Defaults to MERGE_IF_NECESSARY unless
|
||||||
link:project-setup.html#submit_type[Change Submit Actions].
|
link:config-gerrit.html#repository.name.defaultSubmitType[
|
||||||
|
repository.<name>.defaultSubmitType] is set to a different value.
|
||||||
|
For more details see link:project-setup.html#submit_type[
|
||||||
|
Change Submit Actions].
|
||||||
|
|
||||||
--use-content-merge::
|
--use-content-merge::
|
||||||
If enabled, Gerrit will try to perform a 3-way merge of text
|
If enabled, Gerrit will try to perform a 3-way merge of text
|
||||||
|
@ -2323,6 +2323,14 @@ to be the default owner of new projects.
|
|||||||
Currently only the repository name `*` is supported.
|
Currently only the repository name `*` is supported.
|
||||||
This is a wildcard designating all repositories.
|
This is a wildcard designating all repositories.
|
||||||
|
|
||||||
|
[[repository.name.defaultSubmitType]]repository.<name>.defaultSubmitType::
|
||||||
|
+
|
||||||
|
The default submit type for newly created projects. Supported values
|
||||||
|
are `MERGE_IF_NECESSARY`, `FAST_FORWARD_ONLY`, `REBASE_IF_NECESSARY`,
|
||||||
|
`MERGE_ALWAYS` and `CHERRY_PICK`.
|
||||||
|
+
|
||||||
|
By default, `MERGE_IF_NECESSARY`.
|
||||||
|
|
||||||
[[repository.name.ownerGroup]]repository.<name>.ownerGroup::
|
[[repository.name.ownerGroup]]repository.<name>.ownerGroup::
|
||||||
+
|
+
|
||||||
A name of a group which exists in the database. Zero, one or many
|
A name of a group which exists in the database. Zero, one or many
|
||||||
|
@ -1478,7 +1478,9 @@ Whether an empty initial commit should be created.
|
|||||||
The submit type that should be set for the project
|
The submit type that should be set for the project
|
||||||
(`MERGE_IF_NECESSARY`, `REBASE_IF_NECESSARY`, `FAST_FORWARD_ONLY`,
|
(`MERGE_IF_NECESSARY`, `REBASE_IF_NECESSARY`, `FAST_FORWARD_ONLY`,
|
||||||
`MERGE_ALWAYS`, `CHERRY_PICK`). +
|
`MERGE_ALWAYS`, `CHERRY_PICK`). +
|
||||||
If not set, `MERGE_IF_NECESSARY` is set as submit type.
|
If not set, `MERGE_IF_NECESSARY` is set as submit type unless
|
||||||
|
link:config-gerrit.html#repository.name.defaultSubmitType[
|
||||||
|
repository.<name>.defaultSubmitType] is set to a different value.
|
||||||
|`branches` |optional|
|
|`branches` |optional|
|
||||||
A list of branches that should be initially created. +
|
A list of branches that should be initially created. +
|
||||||
For the branch names the `refs/heads/` prefix can be omitted.
|
For the branch names the `refs/heads/` prefix can be omitted.
|
||||||
|
@ -101,8 +101,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, Input> {
|
|||||||
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);
|
||||||
args.submitType =
|
args.submitType = input.submitType;
|
||||||
Objects.firstNonNull(input.submitType, SubmitType.MERGE_IF_NECESSARY);
|
|
||||||
args.branch = input.branches;
|
args.branch = input.branches;
|
||||||
if (input.owners != null) {
|
if (input.owners != null) {
|
||||||
List<AccountGroup.UUID> ownerIds =
|
List<AccountGroup.UUID> ownerIds =
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.gerrit.common.ProjectUtil;
|
import com.google.gerrit.common.ProjectUtil;
|
||||||
import com.google.gerrit.common.data.AccessSection;
|
import com.google.gerrit.common.data.AccessSection;
|
||||||
import com.google.gerrit.common.data.GroupDescription;
|
import com.google.gerrit.common.data.GroupDescription;
|
||||||
@ -25,9 +26,11 @@ import com.google.gerrit.extensions.events.NewProjectCreatedListener;
|
|||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
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.reviewdb.client.Project.SubmitType;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.GroupBackend;
|
import com.google.gerrit.server.account.GroupBackend;
|
||||||
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.ProjectOwnerGroups;
|
import com.google.gerrit.server.config.ProjectOwnerGroups;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
@ -40,6 +43,7 @@ import com.google.inject.assistedinject.Assisted;
|
|||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||||
import org.eclipse.jgit.lib.CommitBuilder;
|
import org.eclipse.jgit.lib.CommitBuilder;
|
||||||
|
import org.eclipse.jgit.lib.Config;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
@ -66,6 +70,7 @@ public class PerformCreateProject {
|
|||||||
PerformCreateProject create(CreateProjectArgs createProjectArgs);
|
PerformCreateProject create(CreateProjectArgs createProjectArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final Config cfg;
|
||||||
private final Set<AccountGroup.UUID> projectOwnerGroups;
|
private final Set<AccountGroup.UUID> projectOwnerGroups;
|
||||||
private final IdentifiedUser currentUser;
|
private final IdentifiedUser currentUser;
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
@ -78,13 +83,15 @@ public class PerformCreateProject {
|
|||||||
private final MetaDataUpdate.User metaDataUpdateFactory;
|
private final MetaDataUpdate.User metaDataUpdateFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PerformCreateProject(@ProjectOwnerGroups Set<AccountGroup.UUID> pOwnerGroups,
|
PerformCreateProject(@GerritServerConfig Config cfg,
|
||||||
|
@ProjectOwnerGroups Set<AccountGroup.UUID> pOwnerGroups,
|
||||||
IdentifiedUser identifiedUser, GitRepositoryManager gitRepoManager,
|
IdentifiedUser identifiedUser, GitRepositoryManager gitRepoManager,
|
||||||
GitReferenceUpdated referenceUpdated,
|
GitReferenceUpdated referenceUpdated,
|
||||||
DynamicSet<NewProjectCreatedListener> createdListener,
|
DynamicSet<NewProjectCreatedListener> createdListener,
|
||||||
@GerritPersonIdent PersonIdent personIdent, GroupBackend groupBackend,
|
@GerritPersonIdent PersonIdent personIdent, GroupBackend groupBackend,
|
||||||
MetaDataUpdate.User metaDataUpdateFactory,
|
MetaDataUpdate.User metaDataUpdateFactory,
|
||||||
@Assisted CreateProjectArgs createPArgs, ProjectCache pCache) {
|
@Assisted CreateProjectArgs createPArgs, ProjectCache pCache) {
|
||||||
|
this.cfg = cfg;
|
||||||
this.projectOwnerGroups = pOwnerGroups;
|
this.projectOwnerGroups = pOwnerGroups;
|
||||||
this.currentUser = identifiedUser;
|
this.currentUser = identifiedUser;
|
||||||
this.repoManager = gitRepoManager;
|
this.repoManager = gitRepoManager;
|
||||||
@ -179,7 +186,8 @@ public class PerformCreateProject {
|
|||||||
|
|
||||||
Project newProject = config.getProject();
|
Project newProject = config.getProject();
|
||||||
newProject.setDescription(createProjectArgs.projectDescription);
|
newProject.setDescription(createProjectArgs.projectDescription);
|
||||||
newProject.setSubmitType(createProjectArgs.submitType);
|
newProject.setSubmitType(Objects.firstNonNull(createProjectArgs.submitType,
|
||||||
|
cfg.getEnum("repository", "*", "defaultSubmitType", SubmitType.MERGE_IF_NECESSARY)));
|
||||||
newProject
|
newProject
|
||||||
.setUseContributorAgreements(createProjectArgs.contributorAgreements);
|
.setUseContributorAgreements(createProjectArgs.contributorAgreements);
|
||||||
newProject.setUseSignedOffBy(createProjectArgs.signedOffBy);
|
newProject.setUseSignedOffBy(createProjectArgs.signedOffBy);
|
||||||
|
@ -63,9 +63,8 @@ final class CreateProjectCommand extends SshCommand {
|
|||||||
@Option(name = "--description", aliases = {"-d"}, metaVar = "DESCRIPTION", usage = "description of project")
|
@Option(name = "--description", aliases = {"-d"}, metaVar = "DESCRIPTION", usage = "description of project")
|
||||||
private String projectDescription = "";
|
private String projectDescription = "";
|
||||||
|
|
||||||
@Option(name = "--submit-type", aliases = {"-t"}, usage = "project submit type\n"
|
@Option(name = "--submit-type", aliases = {"-t"}, usage = "project submit type")
|
||||||
+ "(default: MERGE_IF_NECESSARY)")
|
private SubmitType submitType;
|
||||||
private SubmitType submitType = SubmitType.MERGE_IF_NECESSARY;
|
|
||||||
|
|
||||||
@Option(name = "--contributor-agreements", usage = "if contributor agreement is required")
|
@Option(name = "--contributor-agreements", usage = "if contributor agreement is required")
|
||||||
private InheritableBoolean contributorAgreements = InheritableBoolean.INHERIT;
|
private InheritableBoolean contributorAgreements = InheritableBoolean.INHERIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user