Merge "Disable draft magic branch option per default" into stable-2.15
This commit is contained in:
@@ -1097,6 +1097,17 @@ Allow blame on side by side diff. If set to false, blame cannot be used.
|
||||
+
|
||||
Default is true.
|
||||
|
||||
[[change.allowDrafts]]change.allowDrafts::
|
||||
+
|
||||
Legacy support for drafts workflow. If set to true, pushing a new change
|
||||
with draft option will create a private change. Pushing with draft option
|
||||
to an existing change will create change edit.
|
||||
+
|
||||
Enabling this option allows to push to the `refs/drafts/branch`. When
|
||||
disabled any push to `refs/drafts/branch` will be rejected.
|
||||
+
|
||||
Default is false.
|
||||
|
||||
[[change.cacheAutomerge]]change.cacheAutomerge::
|
||||
+
|
||||
When reviewing diff commits, the left-hand side shows the output of the
|
||||
|
||||
@@ -59,6 +59,7 @@ public class DisablePrivateChangesIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "change.allowDrafts", value = "true")
|
||||
@GerritConfig(name = "change.disablePrivateChanges", value = "true")
|
||||
public void pushDraftsWithDisablePrivateChangesTrue() throws Exception {
|
||||
RevCommit initialHead = getRemoteHead();
|
||||
@@ -81,6 +82,7 @@ public class DisablePrivateChangesIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "change.allowDrafts", value = "true")
|
||||
public void pushPrivatesWithDisablePrivateChangesFalse() throws Exception {
|
||||
PushOneCommit.Result result =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo).to("refs/for/master%private");
|
||||
@@ -88,6 +90,7 @@ public class DisablePrivateChangesIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "change.allowDrafts", value = "true")
|
||||
public void pushDraftsWithDisablePrivateChangesFalse() throws Exception {
|
||||
RevCommit initialHead = getRemoteHead();
|
||||
PushOneCommit.Result result =
|
||||
|
||||
@@ -1859,6 +1859,16 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
assertThat(getPublishedComments(r.getChangeId())).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pushWithDraftOptionIsDisabledPerDefault() throws Exception {
|
||||
for (String ref : ImmutableSet.of("refs/drafts/master", "refs/for/master%draft")) {
|
||||
PushOneCommit.Result r = pushTo(ref);
|
||||
r.assertErrorStatus();
|
||||
r.assertMessage("draft workflow is disabled");
|
||||
}
|
||||
}
|
||||
|
||||
@GerritConfig(name = "change.allowDrafts", value = "true")
|
||||
@Test
|
||||
public void pushDraftGetsPrivateChange() throws Exception {
|
||||
String changeId1 = createChange("refs/drafts/master").getChangeId();
|
||||
@@ -1875,6 +1885,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
assertThat(info2.revisions).hasSize(1);
|
||||
}
|
||||
|
||||
@GerritConfig(name = "change.allowDrafts", value = "true")
|
||||
@Sandboxed
|
||||
@Test
|
||||
public void pushWithDraftOptionToExistingNewChangeGetsChangeEdit() throws Exception {
|
||||
|
||||
@@ -1502,6 +1502,14 @@ class ReceiveCommits {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(davido): Remove legacy support for drafts magic branch option
|
||||
// after repo-tool supports private and work-in-progress changes.
|
||||
if (magicBranch.draft && !receiveConfig.allowDrafts) {
|
||||
errors.put(ReceiveError.CODE_REVIEW, ref);
|
||||
reject(cmd, "draft workflow is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (magicBranch.isPrivate && magicBranch.removePrivate) {
|
||||
reject(cmd, "the options 'private' and 'remove-private' are mutually exclusive");
|
||||
return;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.eclipse.jgit.lib.Config;
|
||||
class ReceiveConfig {
|
||||
final boolean checkMagicRefs;
|
||||
final boolean checkReferencedObjectsAreReachable;
|
||||
final boolean allowDrafts;
|
||||
final int maxBatchCommits;
|
||||
final boolean disablePrivateChanges;
|
||||
private final int systemMaxBatchChanges;
|
||||
@@ -37,6 +38,7 @@ class ReceiveConfig {
|
||||
checkMagicRefs = config.getBoolean("receive", null, "checkMagicRefs", true);
|
||||
checkReferencedObjectsAreReachable =
|
||||
config.getBoolean("receive", null, "checkReferencedObjectsAreReachable", true);
|
||||
allowDrafts = config.getBoolean("change", null, "allowDrafts", false);
|
||||
maxBatchCommits = config.getInt("receive", null, "maxBatchCommits", 10000);
|
||||
systemMaxBatchChanges = config.getInt("receive", "maxBatchChanges", 0);
|
||||
disablePrivateChanges = config.getBoolean("change", null, "disablePrivateChanges", false);
|
||||
|
||||
Reference in New Issue
Block a user