Completely remove support for pushing to refs/drafts

Support for pushing to refs/drafts was kept after the drafts feature
was removed, for backwards compatibility with the repo tool which at
the time did not yet have support for the private and work-in-progress
workflows.

The repo tool has since been updated to support those workflows, so
we can now remove the legacy support for pushing to refs/drafts.

Change-Id: Iaa3629f927cb327b1821208eb0d237a8e00b56bb
This commit is contained in:
David Pursehouse
2019-09-27 17:57:06 +09:00
parent 897a9c218a
commit 9c471d594c
8 changed files with 8 additions and 209 deletions

View File

@@ -53,7 +53,6 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.GerritConfig;
import com.google.gerrit.acceptance.GitUtil;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.Sandboxed;
import com.google.gerrit.acceptance.SkipProjectClone;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.acceptance.TestProjectInput;
@@ -83,7 +82,6 @@ import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.extensions.common.testing.EditInfoSubject;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.registration.RegistrationHandle;
import com.google.gerrit.git.ObjectIds;
@@ -2199,53 +2197,6 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
amendChanges(unChanged.toObjectId(), commits, "refs/for/master%publish-comments");
}
@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();
String changeId2 = createChange("refs/for/master%draft").getChangeId();
ChangeInfo info1 = gApi.changes().id(changeId1).get();
ChangeInfo info2 = gApi.changes().id(changeId2).get();
assertThat(info1.status).isEqualTo(ChangeStatus.NEW);
assertThat(info2.status).isEqualTo(ChangeStatus.NEW);
assertThat(info1.isPrivate).isTrue();
assertThat(info2.isPrivate).isTrue();
assertThat(info1.revisions).hasSize(1);
assertThat(info2.revisions).hasSize(1);
}
@GerritConfig(name = "change.allowDrafts", value = "true")
@Sandboxed
@Test
public void pushWithDraftOptionToExistingNewChangeGetsChangeEdit() throws Exception {
String changeId = createChange().getChangeId();
EditInfoSubject.assertThat(getEdit(changeId)).isAbsent();
ChangeInfo changeInfo = gApi.changes().id(changeId).get();
ChangeStatus originalChangeStatus = changeInfo.status;
PushOneCommit.Result result = amendChange(changeId, "refs/drafts/master");
result.assertOkStatus();
changeInfo = gApi.changes().id(changeId).get();
assertThat(changeInfo.status).isEqualTo(originalChangeStatus);
assertThat(changeInfo.isPrivate).isNull();
assertThat(changeInfo.revisions).hasSize(1);
EditInfoSubject.assertThat(getEdit(changeId)).isPresent();
}
@GerritConfig(name = "receive.maxBatchCommits", value = "2")
@Test
public void maxBatchCommits() throws Exception {