Add project setting for defaulting new changes to WIP
Feature: Issue 8866 Change-Id: I67b144eb3edfb596cfcfb545b273599d82cc04b1
This commit is contained in:
parent
256c0874c1
commit
9690994111
|
@ -217,6 +217,19 @@ the Git push.
|
|||
Default is `INHERIT`, which means that this property is inherited from
|
||||
the parent project.
|
||||
|
||||
[[change.workInProgressByDefault]]change.workInProgressByDefault::
|
||||
+
|
||||
Controls whether all new changes in the project are set as WIP by default.
|
||||
+
|
||||
Note that a new change will be ready if the `workInProgress` field in
|
||||
link:rest-api-changes.html#change-input[ChangeInput] is set to `false` explicitly
|
||||
when calling the link:rest-api-changes.html#create-change[CreateChange] REST API
|
||||
or the `ready` link:user-upload.html#wip[PushOption] is used during
|
||||
the Git push.
|
||||
+
|
||||
Default is `INHERIT`, which means that this property is inherited from
|
||||
the parent project.
|
||||
|
||||
[[submit-section]]
|
||||
=== Submit section
|
||||
|
||||
|
|
|
@ -2757,14 +2757,17 @@ signed push validation is required on the project.
|
|||
|`reject_implicit_merges`|optional|
|
||||
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
|
||||
implicit merges should be rejected on changes pushed to the project.
|
||||
|`private_by_default` ||
|
||||
|`private_by_default` ||
|
||||
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
|
||||
all new changes are set as private by default.
|
||||
|`max_object_size_limit` ||
|
||||
|`work_in_progress_by_default`||
|
||||
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
|
||||
all new changes are set as work-in-progress by default.
|
||||
|`max_object_size_limit` ||
|
||||
The link:config-gerrit.html#receive.maxObjectSizeLimit[max object size
|
||||
limit] of this project as a link:#max-object-size-limit-info[
|
||||
MaxObjectSizeLimitInfo] entity.
|
||||
|`submit_type` ||
|
||||
|`submit_type` ||
|
||||
The default submit type of the project, can be `MERGE_IF_NECESSARY`,
|
||||
`FAST_FORWARD_ONLY`, `REBASE_IF_NECESSARY`, `REBASE_ALWAYS`, `MERGE_ALWAYS` or
|
||||
`CHERRY_PICK`.
|
||||
|
|
|
@ -431,6 +431,16 @@ public class ChangeIT extends AbstractDaemonTest {
|
|||
assertThat(gApi.changes().id(changeId).get().workInProgress).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWipChangeWithWorkInProgressByDefaultForProject() throws Exception {
|
||||
ConfigInput input = new ConfigInput();
|
||||
input.workInProgressByDefault = InheritableBoolean.TRUE;
|
||||
gApi.projects().name(project.get()).config(input);
|
||||
String changeId =
|
||||
gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
|
||||
assertThat(gApi.changes().id(changeId).get().workInProgress).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setReadyForReviewNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result rready = createChange();
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
// Copyright (C) 2018 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.acceptance.rest.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInput;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||
private Project.NameKey project1;
|
||||
private Project.NameKey project2;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
project1 = createProject("project-1");
|
||||
project2 = createProject("project-2", project1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createChangeWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
||||
ChangeInfo info =
|
||||
gApi.changes().create(new ChangeInput(project2.get(), "master", "empty change")).get();
|
||||
assertThat(info.workInProgress).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createChangeWithWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project2);
|
||||
ChangeInput input = new ChangeInput(project2.get(), "master", "empty change");
|
||||
assertThat(gApi.changes().create(input).get().workInProgress).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createChangeBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project2);
|
||||
ChangeInput input = new ChangeInput(project2.get(), "master", "empty change");
|
||||
input.workInProgress = false;
|
||||
assertThat(gApi.changes().create(input).get().workInProgress).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createChangeWithWorkInProgressByDefaultForProjectInherited() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project1);
|
||||
ChangeInfo info =
|
||||
gApi.changes().create(new ChangeInput(project2.get(), "master", "empty change")).get();
|
||||
assertThat(info.workInProgress).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pushWithWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project2);
|
||||
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pushBypassWorkInProgressByDefaultForProjectEnabled() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project2);
|
||||
assertThat(
|
||||
createChange(project2, "refs/for/master%ready").getChange().change().isWorkInProgress())
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pushWithWorkInProgressByDefaultForProjectDisabled() throws Exception {
|
||||
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pushWorkInProgressByDefaultForProjectInherited() throws Exception {
|
||||
setWorkInProgressByDefaultForProject(project1);
|
||||
assertThat(createChange(project2).getChange().change().isWorkInProgress()).isTrue();
|
||||
}
|
||||
|
||||
private void setWorkInProgressByDefaultForProject(Project.NameKey p) throws Exception {
|
||||
ConfigInput input = new ConfigInput();
|
||||
input.workInProgressByDefault = InheritableBoolean.TRUE;
|
||||
gApi.projects().name(p.get()).config(input);
|
||||
}
|
||||
|
||||
private PushOneCommit.Result createChange(Project.NameKey p) throws Exception {
|
||||
return createChange(p, "refs/for/master");
|
||||
}
|
||||
|
||||
private PushOneCommit.Result createChange(Project.NameKey p, String r) throws Exception {
|
||||
TestRepository<InMemoryRepository> testRepo = cloneProject(p);
|
||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
|
||||
PushOneCommit.Result result = push.to(r);
|
||||
result.assertOkStatus();
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -42,10 +42,13 @@ import com.google.gerrit.extensions.api.changes.DeleteVoteInput;
|
|||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.common.CommitMessageInput;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.change.PostReview;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
|
@ -939,6 +942,14 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
|||
assertThat(sender).notSent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWipChangeWithWorkInProgressByDefaultForProject() throws Exception {
|
||||
setWorkInProgressByDefault(project, InheritableBoolean.TRUE);
|
||||
StagedPreChange spc = stagePreChange("refs/for/master");
|
||||
Truth.assertThat(gApi.changes().id(spc.changeId).get().workInProgress).isTrue();
|
||||
assertThat(sender).notSent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createReviewableChangeWithNotifyOwnerReviewers() throws Exception {
|
||||
stagePreChange("refs/for/master%notify=OWNER_REVIEWERS");
|
||||
|
@ -2616,4 +2627,11 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
|||
// PolyGerrit current immediately follows up with a review.
|
||||
gApi.changes().id(sc.changeId).revision("current").review(ReviewInput.noScore());
|
||||
}
|
||||
|
||||
private void setWorkInProgressByDefault(Project.NameKey p, InheritableBoolean v)
|
||||
throws Exception {
|
||||
ConfigInput input = new ConfigInput();
|
||||
input.workInProgressByDefault = v;
|
||||
gApi.projects().name(p.get()).config(input);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class ConfigInfo {
|
|||
public InheritedBooleanInfo requireSignedPush;
|
||||
public InheritedBooleanInfo rejectImplicitMerges;
|
||||
public InheritedBooleanInfo privateByDefault;
|
||||
public InheritedBooleanInfo workInProgressByDefault;
|
||||
public InheritedBooleanInfo enableReviewerByEmail;
|
||||
public InheritedBooleanInfo matchAuthorToCommitterDate;
|
||||
public MaxObjectSizeLimitInfo maxObjectSizeLimit;
|
||||
|
|
|
@ -30,6 +30,7 @@ public class ConfigInput {
|
|||
public InheritableBoolean requireSignedPush;
|
||||
public InheritableBoolean rejectImplicitMerges;
|
||||
public InheritableBoolean privateByDefault;
|
||||
public InheritableBoolean workInProgressByDefault;
|
||||
public InheritableBoolean enableReviewerByEmail;
|
||||
public InheritableBoolean matchAuthorToCommitterDate;
|
||||
public String maxObjectSizeLimit;
|
||||
|
|
|
@ -79,6 +79,8 @@ public interface AdminConstants extends Constants {
|
|||
|
||||
String privateByDefault();
|
||||
|
||||
String workInProgressByDefault();
|
||||
|
||||
String enableReviewerByEmail();
|
||||
|
||||
String matchAuthorToCommitterDate();
|
||||
|
|
|
@ -31,6 +31,7 @@ requireSignedPush = Require signed push
|
|||
requireChangeID = Require <code>Change-Id</code> in commit message
|
||||
rejectImplicitMerges = Reject implicit merges when changes are pushed for review
|
||||
privateByDefault = Set all new changes private by default
|
||||
workInProgressByDefault = Set all new changes work-in-progress by default
|
||||
headingMaxObjectSizeLimit = Maximum Git object size limit
|
||||
headingGroupOptions = Group Options
|
||||
isVisibleToAll = Make group visible to all registered users.
|
||||
|
|
|
@ -87,6 +87,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||
private ListBox requireSignedPush;
|
||||
private ListBox rejectImplicitMerges;
|
||||
private ListBox privateByDefault;
|
||||
private ListBox workInProgressByDefault;
|
||||
private ListBox enableReviewerByEmail;
|
||||
private ListBox matchAuthorToCommitterDate;
|
||||
private NpTextBox maxObjectSizeLimit;
|
||||
|
@ -197,6 +198,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||
requireChangeID.setEnabled(isOwner);
|
||||
rejectImplicitMerges.setEnabled(isOwner);
|
||||
privateByDefault.setEnabled(isOwner);
|
||||
workInProgressByDefault.setEnabled(isOwner);
|
||||
maxObjectSizeLimit.setEnabled(isOwner);
|
||||
enableReviewerByEmail.setEnabled(isOwner);
|
||||
matchAuthorToCommitterDate.setEnabled(isOwner);
|
||||
|
@ -277,6 +279,10 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||
saveEnabler.listenTo(privateByDefault);
|
||||
grid.addHtml(AdminConstants.I.privateByDefault(), privateByDefault);
|
||||
|
||||
workInProgressByDefault = newInheritedBooleanBox();
|
||||
saveEnabler.listenTo(workInProgressByDefault);
|
||||
grid.addHtml(AdminConstants.I.workInProgressByDefault(), workInProgressByDefault);
|
||||
|
||||
enableReviewerByEmail = newInheritedBooleanBox();
|
||||
saveEnabler.listenTo(enableReviewerByEmail);
|
||||
grid.addHtml(AdminConstants.I.enableReviewerByEmail(), enableReviewerByEmail);
|
||||
|
@ -417,6 +423,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||
}
|
||||
setBool(rejectImplicitMerges, result.rejectImplicitMerges());
|
||||
setBool(privateByDefault, result.privateByDefault());
|
||||
setBool(workInProgressByDefault, result.workInProgressByDefault());
|
||||
setBool(enableReviewerByEmail, result.enableReviewerByEmail());
|
||||
setBool(matchAuthorToCommitterDate, result.matchAuthorToCommitterDate());
|
||||
setSubmitType(result.submitType());
|
||||
|
@ -690,6 +697,7 @@ public class ProjectInfoScreen extends ProjectScreen {
|
|||
rsp,
|
||||
getBool(rejectImplicitMerges),
|
||||
getBool(privateByDefault),
|
||||
getBool(workInProgressByDefault),
|
||||
getBool(enableReviewerByEmail),
|
||||
getBool(matchAuthorToCommitterDate),
|
||||
maxObjectSizeLimit.getText().trim(),
|
||||
|
|
|
@ -60,6 +60,9 @@ public class ConfigInfo extends JavaScriptObject {
|
|||
public final native InheritedBooleanInfo privateByDefault()
|
||||
/*-{ return this.private_by_default; }-*/ ;
|
||||
|
||||
public final native InheritedBooleanInfo workInProgressByDefault()
|
||||
/*-{ return this.work_in_progress_by_default; }-*/ ;
|
||||
|
||||
public final native InheritedBooleanInfo enableReviewerByEmail()
|
||||
/*-{ return this.enable_reviewer_by_email; }-*/ ;
|
||||
|
||||
|
|
|
@ -153,6 +153,7 @@ public class ProjectApi {
|
|||
InheritableBoolean requireSignedPush,
|
||||
InheritableBoolean rejectImplicitMerges,
|
||||
InheritableBoolean privateByDefault,
|
||||
InheritableBoolean workInProgressByDefault,
|
||||
InheritableBoolean enableReviewerByEmail,
|
||||
InheritableBoolean matchAuthorToCommitterDate,
|
||||
String maxObjectSizeLimit,
|
||||
|
@ -175,6 +176,7 @@ public class ProjectApi {
|
|||
}
|
||||
in.setRejectImplicitMerges(rejectImplicitMerges);
|
||||
in.setPrivateByDefault(privateByDefault);
|
||||
in.setWorkInProgressByDefault(workInProgressByDefault);
|
||||
in.setMaxObjectSizeLimit(maxObjectSizeLimit);
|
||||
in.setSubmitType(submitType);
|
||||
in.setState(state);
|
||||
|
@ -311,6 +313,13 @@ public class ProjectApi {
|
|||
|
||||
private native void setPrivateByDefault(String v) /*-{ if(v)this.private_by_default=v; }-*/;
|
||||
|
||||
final void setWorkInProgressByDefault(InheritableBoolean v) {
|
||||
setWorkInProgressByDefault(v.name());
|
||||
}
|
||||
|
||||
private native void setWorkInProgressByDefault(
|
||||
String v) /*-{ if(v)this.work_in_progress_by_default=v; }-*/;
|
||||
|
||||
final void setEnableReviewerByEmail(InheritableBoolean v) {
|
||||
setEnableReviewerByEmailRaw(v.name());
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ public final class Project {
|
|||
|
||||
protected InheritableBoolean rejectImplicitMerges;
|
||||
protected InheritableBoolean privateByDefault;
|
||||
protected InheritableBoolean workInProgressByDefault;
|
||||
|
||||
protected InheritableBoolean enableReviewerByEmail;
|
||||
|
||||
|
@ -122,6 +123,7 @@ public final class Project {
|
|||
enableSignedPush = InheritableBoolean.INHERIT;
|
||||
requireSignedPush = InheritableBoolean.INHERIT;
|
||||
privateByDefault = InheritableBoolean.INHERIT;
|
||||
workInProgressByDefault = InheritableBoolean.INHERIT;
|
||||
enableReviewerByEmail = InheritableBoolean.INHERIT;
|
||||
matchAuthorToCommitterDate = InheritableBoolean.INHERIT;
|
||||
}
|
||||
|
@ -174,6 +176,14 @@ public final class Project {
|
|||
this.privateByDefault = privateByDefault;
|
||||
}
|
||||
|
||||
public InheritableBoolean getWorkInProgressByDefault() {
|
||||
return workInProgressByDefault;
|
||||
}
|
||||
|
||||
public void setWorkInProgressByDefault(InheritableBoolean workInProgressByDefault) {
|
||||
this.workInProgressByDefault = workInProgressByDefault;
|
||||
}
|
||||
|
||||
public InheritableBoolean getEnableReviewerByEmail() {
|
||||
return enableReviewerByEmail;
|
||||
}
|
||||
|
|
|
@ -188,6 +188,11 @@ public class CreateChange
|
|||
throw new MethodNotAllowedException("private changes are disabled");
|
||||
}
|
||||
|
||||
boolean isWorkInProgress =
|
||||
input.workInProgress == null
|
||||
? rsrc.getProjectState().isWorkInProgressByDefault()
|
||||
: input.workInProgress;
|
||||
|
||||
contributorAgreements.check(rsrc.getNameKey(), rsrc.getUser());
|
||||
|
||||
Project.NameKey project = rsrc.getNameKey();
|
||||
|
@ -280,7 +285,7 @@ public class CreateChange
|
|||
}
|
||||
ins.setTopic(topic);
|
||||
ins.setPrivate(isPrivate);
|
||||
ins.setWorkInProgress(input.workInProgress != null && input.workInProgress);
|
||||
ins.setWorkInProgress(isWorkInProgress);
|
||||
ins.setGroups(groups);
|
||||
ins.setNotify(input.notify);
|
||||
ins.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
||||
|
|
|
@ -127,6 +127,7 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||
|
||||
private static final String CHANGE = "change";
|
||||
private static final String KEY_PRIVATE_BY_DEFAULT = "privateByDefault";
|
||||
private static final String KEY_WORK_IN_PROGRESS_BY_DEFAULT = "workInProgressByDefault";
|
||||
|
||||
private static final String SUBMIT = "submit";
|
||||
private static final String KEY_ACTION = "action";
|
||||
|
@ -539,6 +540,9 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||
p.setPrivateByDefault(
|
||||
getEnum(rc, CHANGE, null, KEY_PRIVATE_BY_DEFAULT, InheritableBoolean.INHERIT));
|
||||
|
||||
p.setWorkInProgressByDefault(
|
||||
getEnum(rc, CHANGE, null, KEY_WORK_IN_PROGRESS_BY_DEFAULT, InheritableBoolean.INHERIT));
|
||||
|
||||
p.setEnableReviewerByEmail(
|
||||
getEnum(rc, REVIEWER, null, KEY_ENABLE_REVIEWER_BY_EMAIL, InheritableBoolean.INHERIT));
|
||||
|
||||
|
@ -1120,6 +1124,14 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||
p.getPrivateByDefault(),
|
||||
InheritableBoolean.INHERIT);
|
||||
|
||||
set(
|
||||
rc,
|
||||
CHANGE,
|
||||
null,
|
||||
KEY_WORK_IN_PROGRESS_BY_DEFAULT,
|
||||
p.getWorkInProgressByDefault(),
|
||||
InheritableBoolean.INHERIT);
|
||||
|
||||
set(
|
||||
rc,
|
||||
REVIEWER,
|
||||
|
|
|
@ -2127,6 +2127,7 @@ class ReceiveCommits {
|
|||
}
|
||||
|
||||
private void setChangeId(int id) {
|
||||
possiblyOverrideWorkInProgress();
|
||||
|
||||
changeId = new Change.Id(id);
|
||||
ins =
|
||||
|
@ -2147,6 +2148,15 @@ class ReceiveCommits {
|
|||
}
|
||||
}
|
||||
|
||||
private void possiblyOverrideWorkInProgress() {
|
||||
// When wip or ready explicitly provided, leave it as is.
|
||||
if (magicBranch.workInProgress || magicBranch.ready) {
|
||||
return;
|
||||
}
|
||||
magicBranch.workInProgress =
|
||||
projectCache.get(project.getNameKey()).isWorkInProgressByDefault();
|
||||
}
|
||||
|
||||
private void addOps(BatchUpdate bu) throws RestApiException {
|
||||
checkState(changeId != null, "must call setChangeId before addOps");
|
||||
try {
|
||||
|
|
|
@ -59,6 +59,7 @@ public class ConfigInfoImpl extends ConfigInfo {
|
|||
InheritedBooleanInfo requireSignedPush = new InheritedBooleanInfo();
|
||||
InheritedBooleanInfo rejectImplicitMerges = new InheritedBooleanInfo();
|
||||
InheritedBooleanInfo privateByDefault = new InheritedBooleanInfo();
|
||||
InheritedBooleanInfo workInProgressByDefault = new InheritedBooleanInfo();
|
||||
InheritedBooleanInfo enableReviewerByEmail = new InheritedBooleanInfo();
|
||||
InheritedBooleanInfo matchAuthorToCommitterDate = new InheritedBooleanInfo();
|
||||
|
||||
|
@ -77,6 +78,7 @@ public class ConfigInfoImpl extends ConfigInfo {
|
|||
requireSignedPush.configuredValue = p.getRequireSignedPush();
|
||||
rejectImplicitMerges.configuredValue = p.getRejectImplicitMerges();
|
||||
privateByDefault.configuredValue = p.getPrivateByDefault();
|
||||
workInProgressByDefault.configuredValue = p.getWorkInProgressByDefault();
|
||||
enableReviewerByEmail.configuredValue = p.getEnableReviewerByEmail();
|
||||
matchAuthorToCommitterDate.configuredValue = p.getMatchAuthorToCommitterDate();
|
||||
|
||||
|
@ -91,6 +93,7 @@ public class ConfigInfoImpl extends ConfigInfo {
|
|||
enableSignedPush.inheritedValue = projectState.isEnableSignedPush();
|
||||
requireSignedPush.inheritedValue = projectState.isRequireSignedPush();
|
||||
privateByDefault.inheritedValue = projectState.isPrivateByDefault();
|
||||
workInProgressByDefault.inheritedValue = projectState.isWorkInProgressByDefault();
|
||||
rejectImplicitMerges.inheritedValue = projectState.isRejectImplicitMerges();
|
||||
enableReviewerByEmail.inheritedValue = projectState.isEnableReviewerByEmail();
|
||||
matchAuthorToCommitterDate.inheritedValue = projectState.isMatchAuthorToCommitterDate();
|
||||
|
@ -109,6 +112,7 @@ public class ConfigInfoImpl extends ConfigInfo {
|
|||
this.requireSignedPush = requireSignedPush;
|
||||
}
|
||||
this.privateByDefault = privateByDefault;
|
||||
this.workInProgressByDefault = workInProgressByDefault;
|
||||
|
||||
MaxObjectSizeLimitInfo maxObjectSizeLimit = new MaxObjectSizeLimitInfo();
|
||||
maxObjectSizeLimit.value =
|
||||
|
|
|
@ -411,6 +411,10 @@ public class ProjectState {
|
|||
return getInheritableBoolean(Project::getPrivateByDefault);
|
||||
}
|
||||
|
||||
public boolean isWorkInProgressByDefault() {
|
||||
return getInheritableBoolean(Project::getWorkInProgressByDefault);
|
||||
}
|
||||
|
||||
public boolean isEnableReviewerByEmail() {
|
||||
return getInheritableBoolean(Project::getEnableReviewerByEmail);
|
||||
}
|
||||
|
|
|
@ -151,6 +151,10 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
|||
p.setPrivateByDefault(input.privateByDefault);
|
||||
}
|
||||
|
||||
if (input.workInProgressByDefault != null) {
|
||||
p.setWorkInProgressByDefault(input.workInProgressByDefault);
|
||||
}
|
||||
|
||||
if (input.maxObjectSizeLimit != null) {
|
||||
p.setMaxObjectSizeLimit(input.maxObjectSizeLimit);
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ limitations under the License.
|
|||
<label for="wipChangeCheckBox">WIP Change</label>
|
||||
<input
|
||||
type="checkbox"
|
||||
id="wipChangeCheckBox">
|
||||
id="wipChangeCheckBox"
|
||||
checked$="[[_projectConfig.work_in_progress_by_default.inherited_value]]">
|
||||
</section>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,7 @@ limitations under the License.
|
|||
element.projectName = 'test-project';
|
||||
element._projectConfig = {
|
||||
private_by_default: {},
|
||||
work_in_progress_by_default: {},
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -100,6 +101,41 @@ limitations under the License.
|
|||
});
|
||||
});
|
||||
|
||||
test('new change created with wip by default', () => {
|
||||
element._projectConfig = {
|
||||
work_in_progress_by_default: {
|
||||
inherited_value: true,
|
||||
},
|
||||
};
|
||||
|
||||
const configInputObj = {
|
||||
branch: 'test-branch',
|
||||
topic: 'test-topic',
|
||||
subject: 'first change created with polygerrit ui',
|
||||
project: element.projectName,
|
||||
work_in_progress: true,
|
||||
};
|
||||
|
||||
const saveStub = sandbox.stub(element.$.restAPI,
|
||||
'createChange', () => {
|
||||
return Promise.resolve({});
|
||||
});
|
||||
|
||||
element.project = element.projectName;
|
||||
element.branch = 'test-branch';
|
||||
element.topic = 'test-topic';
|
||||
element.subject = 'first change created with polygerrit ui';
|
||||
assert.isTrue(element.$.wipChangeCheckBox.checked);
|
||||
|
||||
element.$.branchInput.bindValue = configInputObj.branch;
|
||||
element.$.tagNameInput.bindValue = configInputObj.topic;
|
||||
element.$.messageInput.bindValue = configInputObj.subject;
|
||||
|
||||
element.handleCreateChange().then(() => {
|
||||
assert.isTrue(saveStub.lastCall.calledWithExactly(configInputObj));
|
||||
});
|
||||
});
|
||||
|
||||
test('new change created with wip', () => {
|
||||
const configInputObj = {
|
||||
branch: 'test-branch',
|
||||
|
|
|
@ -239,6 +239,22 @@ limitations under the License.
|
|||
</gr-select>
|
||||
</span>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">
|
||||
Set new changes to "work in progress" by default</span>
|
||||
<span class="value">
|
||||
<gr-select
|
||||
id="setAllNewChangesWorkInProgressByDefaultSelect"
|
||||
bind-value="{{_projectConfig.work_in_progress_by_default.configured_value}}">
|
||||
<select disabled$="[[_readOnly]]">
|
||||
<template is="dom-repeat"
|
||||
items="[[_formatBooleanSelect(_projectConfig.work_in_progress_by_default)]]">
|
||||
<option value="[[item.value]]">[[item.label]]</option>
|
||||
</template>
|
||||
</select>
|
||||
</gr-select>
|
||||
</span>
|
||||
</section>
|
||||
<section>
|
||||
<span class="title">Maximum Git object size limit</span>
|
||||
<span class="value">
|
||||
|
|
|
@ -89,6 +89,10 @@ limitations under the License.
|
|||
value: false,
|
||||
configured_value: 'FALSE',
|
||||
},
|
||||
work_in_progress_by_default: {
|
||||
value: false,
|
||||
configured_value: 'FALSE',
|
||||
},
|
||||
match_author_to_committer_date: {
|
||||
value: false,
|
||||
configured_value: 'FALSE',
|
||||
|
@ -260,6 +264,7 @@ limitations under the License.
|
|||
require_signed_push: 'TRUE',
|
||||
reject_implicit_merges: 'TRUE',
|
||||
private_by_default: 'TRUE',
|
||||
work_in_progress_by_default: 'TRUE',
|
||||
match_author_to_committer_date: 'TRUE',
|
||||
max_object_size_limit: 10,
|
||||
submit_type: 'FAST_FORWARD_ONLY',
|
||||
|
@ -294,6 +299,8 @@ limitations under the License.
|
|||
configInputObj.reject_implicit_merges;
|
||||
element.$.setAllnewChangesPrivateByDefaultSelect.bindValue =
|
||||
configInputObj.private_by_default;
|
||||
element.$.setAllNewChangesWorkInProgressByDefaultSelect.bindValue =
|
||||
configInputObj.work_in_progress_by_default;
|
||||
element.$.matchAuthoredDateWithCommitterDateSelect.bindValue =
|
||||
configInputObj.match_author_to_committer_date;
|
||||
element.$.maxGitObjSizeInput.bindValue =
|
||||
|
|
Loading…
Reference in New Issue