Start using TestRepository instead of Git in tests

The add, rm, and checkout methods in GitUtil (among others) require a
non-bare repository, which implies local disk. In order to make tests
faster, we would like to move these repositories entirely into bare
InMemoryRepositorys. As a start, convert PushOneCommit to store a
CommitBuilder and use its add/rm methods instead of depending on the
local filesystem to store state. Instead of checkout, use the new
reset method on TestRepository.

Change-Id: Icb286719bc99dae841f2a234677524abd7f144dc
This commit is contained in:
Dave Borowitz
2015-03-11 17:34:25 -07:00
committed by David Pursehouse
parent b074c9f74f
commit 7dadbcf3f1
27 changed files with 261 additions and 306 deletions

View File

@@ -59,9 +59,9 @@ import com.google.inject.util.Providers;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.Config;
import org.junit.Rule;
import org.junit.rules.TestRule;
@@ -123,6 +123,7 @@ public abstract class AbstractDaemonTest {
protected @GerritServerConfig Config cfg;
protected Git git;
protected TestRepository<?> testRepo;
protected GerritServer server;
protected TestAccount admin;
protected TestAccount user;
@@ -205,7 +206,7 @@ public abstract class AbstractDaemonTest {
project = new Project.NameKey(projectInput.name);
createProject(projectInput);
git = cloneProject(sshSession.getUrl() + "/" + project.get());
setRepo(cloneProject(sshSession.getUrl() + "/" + project.get()));
}
private ProjectInput projectInput(Description description) {
@@ -231,6 +232,11 @@ public abstract class AbstractDaemonTest {
return in;
}
protected void setRepo(Git git) throws Exception {
this.git = git;
testRepo = new TestRepository<>(git.getRepository());
}
protected void createProject(String name) throws RestApiException {
createProject(name, null);
}
@@ -275,24 +281,23 @@ public abstract class AbstractDaemonTest {
TempFileUtil.cleanup();
}
protected PushOneCommit.Result createChange() throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
protected PushOneCommit.Result createChange() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
return push.to("refs/for/master");
}
private static final List<Character> RANDOM =
Chars.asList(new char[]{'a','b','c','d','e','f','g','h'});
protected PushOneCommit.Result amendChange(String changeId)
throws GitAPIException, IOException {
throws Exception {
return amendChange(changeId, "refs/for/master");
}
protected PushOneCommit.Result amendChange(String changeId, String ref)
throws GitAPIException, IOException {
throws Exception {
Collections.shuffle(RANDOM);
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
PushOneCommit.FILE_NAME, new String(Chars.toArray(RANDOM)), changeId);
return push.to(ref);
}
@@ -414,9 +419,8 @@ public abstract class AbstractDaemonTest {
saveProjectConfig(project, cfg);
}
protected PushOneCommit.Result pushTo(String ref) throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
protected PushOneCommit.Result pushTo(String ref) throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
return push.to(ref);
}
}

View File

@@ -25,7 +25,6 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.eclipse.jgit.api.AddCommand;
import org.eclipse.jgit.api.CheckoutCommand;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.CommitCommand;
import org.eclipse.jgit.api.FetchCommand;
@@ -151,12 +150,6 @@ public class GitUtil {
fetch.call();
}
public static void checkout(Git git, String name) throws GitAPIException {
CheckoutCommand checkout = git.checkout();
checkout.setName(name);
checkout.call();
}
public static PushResult pushHead(Git git, String ref, boolean pushTags)
throws GitAPIException {
return pushHead(git, ref, pushTags, false);

View File

@@ -14,10 +14,8 @@
package com.google.gerrit.acceptance;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.add;
import static com.google.gerrit.acceptance.GitUtil.amendCommit;
import static com.google.gerrit.acceptance.GitUtil.createCommit;
import static com.google.gerrit.acceptance.GitUtil.pushHead;
import com.google.common.base.Function;
@@ -25,7 +23,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.acceptance.GitUtil.Commit;
import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
@@ -42,10 +40,7 @@ import com.google.inject.assistedinject.AssistedInject;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.TagCommand;
import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidTagNameException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -53,8 +48,8 @@ import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.RemoteRefUpdate;
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class PushOneCommit {
@@ -66,12 +61,12 @@ public class PushOneCommit {
PushOneCommit create(
ReviewDb db,
PersonIdent i,
Git git);
TestRepository<?> testRepo);
PushOneCommit create(
ReviewDb db,
PersonIdent i,
Git git,
TestRepository<?> testRepo,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content);
@@ -79,7 +74,7 @@ public class PushOneCommit {
PushOneCommit create(
ReviewDb db,
PersonIdent i,
Git git,
TestRepository<?> testRepo,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content,
@@ -109,8 +104,7 @@ public class PushOneCommit {
private final ApprovalsUtil approvalsUtil;
private final Provider<InternalChangeQuery> queryProvider;
private final ReviewDb db;
private final PersonIdent i;
private final Git git;
private final TestRepository<?> testRepo;
private final String subject;
private final String fileName;
@@ -119,15 +113,17 @@ public class PushOneCommit {
private Tag tag;
private boolean force;
private final TestRepository<?>.CommitBuilder commitBuilder;
@AssistedInject
PushOneCommit(ChangeNotes.Factory notesFactory,
ApprovalsUtil approvalsUtil,
Provider<InternalChangeQuery> queryProvider,
@Assisted ReviewDb db,
@Assisted PersonIdent i,
@Assisted Git git) {
@Assisted TestRepository<?> testRepo) throws Exception {
this(notesFactory, approvalsUtil, queryProvider,
db, i, git, SUBJECT, FILE_NAME, FILE_CONTENT);
db, i, testRepo, SUBJECT, FILE_NAME, FILE_CONTENT);
}
@AssistedInject
@@ -136,12 +132,12 @@ public class PushOneCommit {
Provider<InternalChangeQuery> queryProvider,
@Assisted ReviewDb db,
@Assisted PersonIdent i,
@Assisted Git git,
@Assisted TestRepository<?> testRepo,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content) {
@Assisted("content") String content) throws Exception {
this(notesFactory, approvalsUtil, queryProvider,
db, i, git, subject, fileName, content, null);
db, i, testRepo, subject, fileName, content, null);
}
@AssistedInject
@@ -150,42 +146,49 @@ public class PushOneCommit {
Provider<InternalChangeQuery> queryProvider,
@Assisted ReviewDb db,
@Assisted PersonIdent i,
@Assisted Git git,
@Assisted TestRepository<?> testRepo,
@Assisted("subject") String subject,
@Assisted("fileName") String fileName,
@Assisted("content") String content,
@Nullable @Assisted("changeId") String changeId) {
@Nullable @Assisted("changeId") String changeId) throws Exception {
this.db = db;
this.testRepo = testRepo;
this.notesFactory = notesFactory;
this.approvalsUtil = approvalsUtil;
this.queryProvider = queryProvider;
this.i = i;
this.git = git;
this.subject = subject;
this.fileName = fileName;
this.content = content;
this.changeId = changeId;
}
public Result to(String ref) throws GitAPIException, IOException {
add(git, fileName, content);
return execute(ref);
}
public Result rm(String ref) throws GitAPIException {
GitUtil.rm(git, fileName);
return execute(ref);
}
private Result execute(String ref) throws GitAPIException,
ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException {
Commit c;
if (changeId != null) {
c = amendCommit(git, i, subject, changeId);
commitBuilder = testRepo.amendRef("HEAD")
.insertChangeId(changeId.substring(1));
} else {
c = createCommit(git, i, subject);
changeId = c.getChangeId();
commitBuilder = testRepo.branch("HEAD").commit().insertChangeId();
}
commitBuilder.message(subject).ident(i);
}
public Result to(String ref) throws Exception {
commitBuilder.add(fileName, content);
return execute(ref);
}
public Result rm(String ref) throws Exception {
commitBuilder.rm(fileName);
return execute(ref);
}
private Result execute(String ref) throws Exception {
RevCommit c = commitBuilder.create();
testRepo.getRevWalk().parseBody(c);
if (changeId == null) {
List<String> ids = c.getFooterLines(FooterConstants.CHANGE_ID);
checkState(ids.size() >= 1,
"No Change-Id found in new commit:\n%s", c.getFullMessage());
changeId = ids.get(ids.size() - 1);
}
Git git = Git.wrap(testRepo.getRepository());
if (tag != null) {
TagCommand tagCommand = git.tag().setName(tag.name);
if (tag instanceof AnnotatedTag) {
@@ -212,10 +215,10 @@ public class PushOneCommit {
public class Result {
private final String ref;
private final PushResult result;
private final Commit commit;
private final RevCommit commit;
private final String resSubj;
private Result(String ref, PushResult resSubj, Commit commit,
private Result(String ref, PushResult resSubj, RevCommit commit,
String subject) {
this.ref = ref;
this.result = resSubj;
@@ -225,7 +228,7 @@ public class PushOneCommit {
public ChangeData getChange() throws OrmException {
return Iterables.getOnlyElement(
queryProvider.get().byKeyPrefix(commit.getChangeId()));
queryProvider.get().byKeyPrefix(changeId));
}
public PatchSet getPatchSet() throws OrmException {
@@ -237,15 +240,15 @@ public class PushOneCommit {
}
public String getChangeId() {
return commit.getChangeId();
return changeId;
}
public ObjectId getCommitId() {
return commit.getCommit().getId();
return commit;
}
public RevCommit getCommit() {
return commit.getCommit();
return commit;
}
public void assertChange(Change.Status expectedStatus,

View File

@@ -46,14 +46,12 @@ import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Patch;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.RefUpdate;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
@@ -214,7 +212,7 @@ public class RevisionIT extends AbstractDaemonTest {
String subject = "Test change\n\n" +
"Change-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, subject,
pushFactory.create(db, admin.getIdent(), testRepo, subject,
"another_file.txt", "another content");
PushOneCommit.Result r2 = push.to("refs/for/master");
@@ -283,7 +281,7 @@ public class RevisionIT extends AbstractDaemonTest {
.create(new BranchInput());
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
PushOneCommit.FILE_NAME, "another content");
push.to("refs/heads/foo");
@@ -300,11 +298,11 @@ public class RevisionIT extends AbstractDaemonTest {
@Test
public void canRebase() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
merge(r1);
push = pushFactory.create(db, admin.getIdent(), git);
push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r2 = push.to("refs/for/master");
boolean canRebase = gApi.changes()
.id(r2.getChangeId())
@@ -314,7 +312,7 @@ public class RevisionIT extends AbstractDaemonTest {
merge(r2);
git.checkout().setName(r1.getCommit().name()).call();
push = pushFactory.create(db, admin.getIdent(), git);
push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r3 = push.to("refs/for/master");
canRebase = gApi.changes()
@@ -326,7 +324,7 @@ public class RevisionIT extends AbstractDaemonTest {
@Test
public void setUnsetReviewedFlag() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r = push.to("refs/for/master");
gApi.changes()
@@ -354,7 +352,7 @@ public class RevisionIT extends AbstractDaemonTest {
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
PushOneCommit push1 =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
PushOneCommit.FILE_NAME, "push 1 content");
PushOneCommit.Result r1 = push1.to("refs/for/master");
@@ -367,7 +365,7 @@ public class RevisionIT extends AbstractDaemonTest {
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
PushOneCommit push2 =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
PushOneCommit.FILE_NAME, "push 2 content");
PushOneCommit.Result r2 = push2.to("refs/for/master");
assertMergeable(r2.getChangeId(), false);
@@ -521,15 +519,14 @@ public class RevisionIT extends AbstractDaemonTest {
}
private PushOneCommit.Result updateChange(PushOneCommit.Result r,
String content) throws GitAPIException, IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
String content) throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
"test commit", "a.txt", content, r.getChangeId());
return push.to("refs/for/master");
}
private PushOneCommit.Result createDraft() throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
private PushOneCommit.Result createDraft() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
return push.to("refs/drafts/master");
}
}

View File

@@ -59,7 +59,6 @@ import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import org.apache.commons.codec.binary.StringUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.RefUpdate;
@@ -108,12 +107,12 @@ public class ChangeEditIT extends AbstractDaemonTest {
@Before
public void setUp() throws Exception {
db = reviewDbProvider.open();
changeId = newChange(git, admin.getIdent());
changeId = newChange(admin.getIdent());
ps = getCurrentPatchSet(changeId);
amendChange(git, admin.getIdent(), changeId);
amendChange(admin.getIdent(), changeId);
change = getChange(changeId);
assertThat(ps).isNotNull();
changeId2 = newChange2(git, admin.getIdent());
changeId2 = newChange2(admin.getIdent());
change2 = getChange(changeId2);
assertThat(change2).isNotNull();
ps2 = getCurrentPatchSet(changeId2);
@@ -244,7 +243,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
current.getPatchSetId());
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT, FILE_NAME,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, FILE_NAME,
new String(CONTENT_NEW2), changeId2);
push.to("refs/for/master").assertOkStatus();
RestResponse r = adminSession.post(urlRebase());
@@ -268,8 +267,8 @@ public class ChangeEditIT extends AbstractDaemonTest {
@Test
@TestProjectInput(createEmptyCommit = false)
public void updateRootCommitMessage() throws Exception {
git = cloneProject(sshSession.getUrl() + "/" + project);
changeId = newChange(git, admin.getIdent());
setRepo(cloneProject(sshSession.getUrl() + "/" + project));
changeId = newChange(admin.getIdent());
change = getChange(changeId);
assertThat(modifier.createEdit(change, getCurrentPatchSet(changeId)))
@@ -653,23 +652,23 @@ public class ChangeEditIT extends AbstractDaemonTest {
assertThat(approvals.get(0).value).isEqualTo(1);
}
private String newChange(Git git, PersonIdent ident) throws Exception {
private String newChange(PersonIdent ident) throws Exception {
PushOneCommit push =
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME,
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
new String(CONTENT_OLD));
return push.to("refs/for/master").getChangeId();
}
private String amendChange(Git git, PersonIdent ident, String changeId) throws Exception {
private String amendChange(PersonIdent ident, String changeId) throws Exception {
PushOneCommit push =
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME2,
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME2,
new String(CONTENT_NEW2), changeId);
return push.to("refs/for/master").getChangeId();
}
private String newChange2(Git git, PersonIdent ident) throws Exception {
private String newChange2(PersonIdent ident) throws Exception {
PushOneCommit push =
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME,
pushFactory.create(db, ident, testRepo, PushOneCommit.SUBJECT, FILE_NAME,
new String(CONTENT_OLD));
return push.rm("refs/for/master").getChangeId();
}

View File

@@ -25,21 +25,15 @@ import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.notedb.NotesMigration;
import com.google.gerrit.testutil.ConfigSuite;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.jcraft.jsch.JSchException;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Config;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.Set;
public abstract class AbstractPushForReview extends AbstractDaemonTest {
@@ -62,7 +56,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
sshUrl = sshSession.getUrl();
}
protected void selectProtocol(Protocol p) throws GitAPIException, IOException {
protected void selectProtocol(Protocol p) throws Exception {
String url;
switch (p) {
case SSH:
@@ -74,20 +68,18 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
default:
throw new IllegalArgumentException("unexpected protocol: " + p);
}
git = cloneProject(url + "/" + project.get());
setRepo(cloneProject(url + "/" + project.get()));
}
@Test
public void testPushForMaster() throws GitAPIException, OrmException,
IOException {
public void testPushForMaster() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
r.assertChange(Change.Status.NEW, null);
}
@Test
public void testPushForMasterWithTopic() throws GitAPIException,
OrmException, IOException {
public void testPushForMasterWithTopic() throws Exception {
// specify topic in ref
String topic = "my/topic";
PushOneCommit.Result r = pushTo("refs/for/master/" + topic);
@@ -101,8 +93,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterWithCc() throws GitAPIException, OrmException,
IOException, JSchException {
public void testPushForMasterWithCc() throws Exception {
// cc one user
String topic = "my/topic";
PushOneCommit.Result r = pushTo("refs/for/master/" + topic + "%cc=" + user.email);
@@ -125,8 +116,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterWithReviewer() throws GitAPIException,
OrmException, IOException, JSchException {
public void testPushForMasterWithReviewer() throws Exception {
// add one reviewer
String topic = "my/topic";
PushOneCommit.Result r = pushTo("refs/for/master/" + topic + "%r=" + user.email);
@@ -150,8 +140,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterAsDraft() throws GitAPIException, OrmException,
IOException {
public void testPushForMasterAsDraft() throws Exception {
// create draft by pushing to 'refs/drafts/'
PushOneCommit.Result r = pushTo("refs/drafts/master");
r.assertOkStatus();
@@ -164,8 +153,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterAsEdit() throws GitAPIException,
IOException, RestApiException {
public void testPushForMasterAsEdit() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
EditInfo edit = getEdit(r.getChangeId());
@@ -179,8 +167,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterWithApprovals() throws GitAPIException,
IOException, RestApiException {
public void testPushForMasterWithApprovals() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master/%l=Code-Review");
r.assertOkStatus();
ChangeInfo ci = get(r.getChangeId());
@@ -190,7 +177,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
assertThat(cr.all.get(0).value).is(1);
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master/%l=Code-Review+2");
@@ -202,42 +189,37 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushNewPatchsetToRefsChanges() throws GitAPIException,
IOException, OrmException {
public void testPushNewPatchsetToRefsChanges() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/changes/" + r.getChange().change().getId().get());
r.assertOkStatus();
}
@Test
public void testPushForMasterWithApprovals_MissingLabel() throws GitAPIException,
IOException {
public void testPushForMasterWithApprovals_MissingLabel() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master/%l=Verify");
r.assertErrorStatus("label \"Verify\" is not a configured label");
}
@Test
public void testPushForMasterWithApprovals_ValueOutOfRange() throws GitAPIException,
IOException {
public void testPushForMasterWithApprovals_ValueOutOfRange() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master/%l=Code-Review-3");
r.assertErrorStatus("label \"Code-Review\": -3 is not a valid value");
}
@Test
public void testPushForNonExistingBranch() throws GitAPIException,
IOException {
public void testPushForNonExistingBranch() throws Exception {
String branchName = "non-existing";
PushOneCommit.Result r = pushTo("refs/for/" + branchName);
r.assertErrorStatus("branch " + branchName + " not found");
}
@Test
public void testPushForMasterWithHashtags() throws GitAPIException,
OrmException, IOException, RestApiException {
public void testPushForMasterWithHashtags() throws Exception {
// Hashtags currently only work when noteDB is enabled
assume().that(notesMigration.enabled()).isTrue();
@@ -255,7 +237,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
// specify a single hashtag as option in new patch set
String hashtag2 = "tag2";
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master/%hashtag=" + hashtag2);
r.assertOkStatus();
@@ -265,8 +247,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterWithMultipleHashtags() throws GitAPIException,
OrmException, IOException, RestApiException {
public void testPushForMasterWithMultipleHashtags() throws Exception {
// Hashtags currently only work when noteDB is enabled
assume().that(notesMigration.enabled()).isTrue();
@@ -287,7 +268,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
String hashtag3 = "tag3";
String hashtag4 = "tag4";
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master%hashtag=" + hashtag3 + ",hashtag=" + hashtag4);
r.assertOkStatus();
@@ -297,8 +278,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
}
@Test
public void testPushForMasterWithHashtagsNoteDbDisabled() throws GitAPIException,
IOException {
public void testPushForMasterWithHashtagsNoteDbDisabled() throws Exception {
// push with hashtags should fail when noteDb is disabled
assume().that(notesMigration.enabled()).isFalse();
PushOneCommit.Result r = pushTo("refs/for/master%hashtag=tag1");

View File

@@ -31,7 +31,7 @@ public class ForcePushIT extends AbstractDaemonTest {
public void forcePushNotAllowed() throws Exception {
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
PushOneCommit push1 =
pushFactory.create(db, admin.getIdent(), git, "change1", "a.txt", "content");
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
PushOneCommit.Result r1 = push1.to("refs/heads/master");
r1.assertOkStatus();
@@ -41,7 +41,7 @@ public class ForcePushIT extends AbstractDaemonTest {
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
PushOneCommit push2 =
pushFactory.create(db, admin.getIdent(), git, "change2", "b.txt", "content");
pushFactory.create(db, admin.getIdent(), testRepo, "change2", "b.txt", "content");
push2.setForce(true);
PushOneCommit.Result r2 = push2.to("refs/heads/master");
r2.assertErrorStatus("non-fast forward");
@@ -52,7 +52,7 @@ public class ForcePushIT extends AbstractDaemonTest {
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
grant(Permission.PUSH, project, "refs/*", true);
PushOneCommit push1 =
pushFactory.create(db, admin.getIdent(), git, "change1", "a.txt", "content");
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
PushOneCommit.Result r1 = push1.to("refs/heads/master");
r1.assertOkStatus();
@@ -62,7 +62,7 @@ public class ForcePushIT extends AbstractDaemonTest {
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
PushOneCommit push2 =
pushFactory.create(db, admin.getIdent(), git, "change2", "b.txt", "content");
pushFactory.create(db, admin.getIdent(), testRepo, "change2", "b.txt", "content");
push2.setForce(true);
PushOneCommit.Result r2 = push2.to("refs/heads/master");
r2.assertOkStatus();

View File

@@ -32,7 +32,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
@@ -73,7 +72,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
grant(Permission.CREATE, project, "refs/tags/*");
grant(Permission.PUSH, project, "refs/tags/*");
PushOneCommit.Tag tag = new PushOneCommit.Tag("v1.0");
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
push.setTag(tag);
PushOneCommit.Result r = push.to("refs/for/master%submit");
r.assertOkStatus();
@@ -90,7 +89,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
grant(Permission.PUSH, project, "refs/tags/*");
PushOneCommit.AnnotatedTag tag =
new PushOneCommit.AnnotatedTag("v1.0", "annotation", admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
push.setTag(tag);
PushOneCommit.Result r = push.to("refs/for/master%submit");
r.assertOkStatus();
@@ -271,16 +270,15 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
}
private PushOneCommit.Result push(String ref, String subject,
String fileName, String content) throws GitAPIException, IOException {
String fileName, String content) throws Exception {
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
pushFactory.create(db, admin.getIdent(), testRepo, subject, fileName, content);
return push.to(ref);
}
private PushOneCommit.Result push(String ref, String subject,
String fileName, String content, String changeId) throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git, subject,
String fileName, String content, String changeId) throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, subject,
fileName, content, changeId);
return push.to(ref);
}

View File

@@ -91,10 +91,10 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
.create(new BranchInput());
allow(Permission.SUBMIT, admins, "refs/for/refs/heads/*");
PushOneCommit.Result mr = pushFactory.create(db, admin.getIdent(), git)
PushOneCommit.Result mr = pushFactory.create(db, admin.getIdent(), testRepo)
.to("refs/for/master%submit");
mr.assertOkStatus();
PushOneCommit.Result br = pushFactory.create(db, admin.getIdent(), git)
PushOneCommit.Result br = pushFactory.create(db, admin.getIdent(), testRepo)
.to("refs/for/branch%submit");
br.assertOkStatus();

View File

@@ -59,7 +59,6 @@ import com.google.inject.Inject;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.ObjectId;
@@ -126,7 +125,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
@Test
@TestProjectInput(createEmptyCommit = false)
public void submitToEmptyRepo() throws Exception {
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
assertThat(getRemoteHead().getId()).isEqualTo(change.getCommitId());
}
@@ -135,11 +134,11 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
public void submitWholeTopic() throws Exception {
assume().that(isSubmitWholeTopicEnabled()).isTrue();
PushOneCommit.Result change1 =
createChange(git, "Change 1", "a.txt", "content", "test-topic");
createChange("Change 1", "a.txt", "content", "test-topic");
PushOneCommit.Result change2 =
createChange(git, "Change 2", "b.txt", "content", "test-topic");
createChange("Change 2", "b.txt", "content", "test-topic");
PushOneCommit.Result change3 =
createChange(git, "Change 3", "c.txt", "content", "test-topic");
createChange("Change 3", "c.txt", "content", "test-topic");
approve(change1.getChangeId());
approve(change2.getChangeId());
approve(change3.getChangeId());
@@ -173,24 +172,18 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
}
}
protected PushOneCommit.Result createChange(Git git) throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
return push.to("refs/for/master");
}
protected PushOneCommit.Result createChange(Git git, String subject,
String fileName, String content) throws GitAPIException, IOException {
protected PushOneCommit.Result createChange(String subject,
String fileName, String content) throws Exception {
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
pushFactory.create(db, admin.getIdent(), testRepo, subject, fileName, content);
return push.to("refs/for/master");
}
protected PushOneCommit.Result createChange(Git git, String subject,
protected PushOneCommit.Result createChange(String subject,
String fileName, String content, String topic)
throws GitAPIException, IOException {
throws Exception {
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
pushFactory.create(db, admin.getIdent(), testRepo, subject, fileName, content);
return push.to("refs/for/master/" + topic);
}

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.TestProjectInput;
@@ -30,13 +29,13 @@ public abstract class AbstractSubmitByMerge extends AbstractSubmit {
public void submitWithMerge() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "b.txt", "other content");
createChange("Change 2", "b.txt", "other content");
submit(change2.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getParentCount()).isEqualTo(2);
@@ -48,16 +47,16 @@ public abstract class AbstractSubmitByMerge extends AbstractSubmit {
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "aaa\nbbb\nccc\n");
createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
submit(change.getChangeId());
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
submit(change2.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, change.getCommitId().getName());
testRepo.reset(change.getCommitId());
PushOneCommit.Result change3 =
createChange(git, "Change 3", "a.txt", "bbb\nccc\n");
createChange("Change 3", "a.txt", "bbb\nccc\n");
submit(change3.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getParentCount()).isEqualTo(2);
@@ -70,13 +69,13 @@ public abstract class AbstractSubmitByMerge extends AbstractSubmit {
public void submitWithContentMerge_Conflict() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "other content");
createChange("Change 2", "a.txt", "other content");
submitWithConflict(change2.getChangeId());
assertThat(getRemoteHead()).isEqualTo(oldHead);
}

View File

@@ -26,7 +26,6 @@ import com.google.gerrit.testutil.ConfigSuite;
import com.google.gson.reflect.TypeToken;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Config;
import org.junit.Test;
@@ -127,9 +126,9 @@ public class ActionsIT extends AbstractDaemonTest {
assertThat(actions).containsKey("rebase");
}
private PushOneCommit.Result createChangeWithTopic(String topic) throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
private PushOneCommit.Result createChangeWithTopic(String topic)
throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
assertThat(topic).isNotEmpty();
return push.to("refs/for/master/" + topic);
}

View File

@@ -34,7 +34,6 @@ import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.group.SystemGroupBackend;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.junit.Before;
import org.junit.Test;
@@ -54,7 +53,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
SshSession sshSession = new SshSession(server, user);
initSsh(user);
sshSession.open();
git = cloneProject(sshSession.getUrl() + "/" + project.get());
setRepo(cloneProject(sshSession.getUrl() + "/" + project.get()));
sshSession.close();
user2 = accounts.user2();
sessionDev = new RestSession(server, user2);
@@ -102,9 +101,8 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
projectCache.evict(config.getProject());
}
private String createMyChange() throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, user.getIdent(), git);
private String createMyChange() throws Exception {
PushOneCommit push = pushFactory.create(db, user.getIdent(), testRepo);
return push.to("refs/for/master").getChangeId();
}
}

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
@@ -27,8 +26,6 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gson.reflect.TypeToken;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Test;
import java.io.IOException;
@@ -40,8 +37,8 @@ public class ConflictsOperatorIT extends AbstractDaemonTest {
@Test
public void noConflictingChanges() throws Exception {
PushOneCommit.Result change = createChange(git, true);
createChange(git, false);
PushOneCommit.Result change = createChange(true);
createChange(false);
Set<String> changes = queryConflictingChanges(change);
assertThat((Iterable<?>)changes).isEmpty();
@@ -49,21 +46,21 @@ public class ConflictsOperatorIT extends AbstractDaemonTest {
@Test
public void conflictingChanges() throws Exception {
PushOneCommit.Result change = createChange(git, true);
PushOneCommit.Result conflictingChange1 = createChange(git, true);
PushOneCommit.Result conflictingChange2 = createChange(git, true);
createChange(git, false);
PushOneCommit.Result change = createChange(true);
PushOneCommit.Result conflictingChange1 = createChange(true);
PushOneCommit.Result conflictingChange2 = createChange(true);
createChange(false);
Set<String> changes = queryConflictingChanges(change);
assertChanges(changes, conflictingChange1, conflictingChange2);
}
private PushOneCommit.Result createChange(Git git, boolean conflicting)
throws GitAPIException, IOException {
checkout(git, "origin/master");
private PushOneCommit.Result createChange(boolean conflicting)
throws Exception {
testRepo.reset("origin/master");
String file = conflicting ? "test.txt" : "test-" + count + ".txt";
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, "Change " + count, file,
pushFactory.create(db, admin.getIdent(), testRepo, "Change " + count, file,
"content " + count);
count++;
return push.to("refs/for/master");

View File

@@ -29,7 +29,6 @@ import com.google.gerrit.server.query.change.ChangeData;
import com.google.gwtorm.server.OrmException;
import org.apache.http.HttpStatus;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.junit.Test;
import java.io.IOException;
@@ -79,11 +78,10 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
assertThat(queryProvider.get().byKeyPrefix(changeId)).isEmpty();
}
private String createDraftChangeWith2PS() throws GitAPIException,
IOException {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
private String createDraftChangeWith2PS() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
Result result = push.to("refs/drafts/master");
push = pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
"b.txt", "4711", result.getChangeId());
return push.to("refs/drafts/master").getChangeId();
}

View File

@@ -51,7 +51,7 @@ public class ListChangesOptionsIT extends AbstractDaemonTest {
String subject = "Change subject";
String fileName = "a.txt";
PushOneCommit push = pushFactory.create(
db, admin.getIdent(), git, subject, fileName, content, baseChangeId);
db, admin.getIdent(), testRepo, subject, fileName, content, baseChangeId);
PushOneCommit.Result r = push.to("refs/for/master");
r.assertOkStatus();
return r;

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.common.collect.Iterables;
import com.google.gerrit.acceptance.PushOneCommit;
@@ -40,7 +39,7 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
@Test
public void submitWithCherryPickIfFastForwardPossible() throws Exception {
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
assertCherryPick(git, false);
assertThat(getRemoteHead().getParent(0))
@@ -51,13 +50,13 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitWithCherryPick() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "b.txt", "other content");
createChange("Change 2", "b.txt", "other content");
submit(change2.getChangeId());
assertCherryPick(git, false);
RevCommit newHead = getRemoteHead();
@@ -72,16 +71,16 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "aaa\nbbb\nccc\n");
createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
submit(change.getChangeId());
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
submit(change2.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, change.getCommitId().getName());
testRepo.reset(change.getCommitId());
PushOneCommit.Result change3 =
createChange(git, "Change 3", "a.txt", "bbb\nccc\n");
createChange("Change 3", "a.txt", "bbb\nccc\n");
submit(change3.getChangeId());
assertCherryPick(git, true);
RevCommit newHead = getRemoteHead();
@@ -97,13 +96,13 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitWithContentMerge_Conflict() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "other content");
createChange("Change 2", "a.txt", "other content");
submitWithConflict(change2.getChangeId());
assertThat(getRemoteHead()).isEqualTo(oldHead);
assertCurrentRevision(change2.getChangeId(), 1, change2.getCommitId());
@@ -114,14 +113,14 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitOutOfOrder() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
createChange(git, "Change 2", "b.txt", "other content");
testRepo.reset(initialHead);
createChange("Change 2", "b.txt", "other content");
PushOneCommit.Result change3 =
createChange(git, "Change 3", "c.txt", "different content");
createChange("Change 3", "c.txt", "different content");
submit(change3.getChangeId());
assertCherryPick(git, false);
RevCommit newHead = getRemoteHead();
@@ -136,14 +135,14 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitOutOfOrder_Conflict() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
createChange(git, "Change 2", "b.txt", "other content");
testRepo.reset(initialHead);
createChange("Change 2", "b.txt", "other content");
PushOneCommit.Result change3 =
createChange(git, "Change 3", "b.txt", "different content");
createChange("Change 3", "b.txt", "different content");
submitWithConflict(change3.getChangeId());
assertThat(getRemoteHead()).isEqualTo(oldHead);
assertCurrentRevision(change3.getChangeId(), 1, change3.getCommitId());
@@ -154,14 +153,14 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitMultipleChanges() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change3 = createChange(git, "Change 3", "c", "c");
testRepo.reset(initialHead);
PushOneCommit.Result change3 = createChange("Change 3", "c", "c");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change4 = createChange(git, "Change 4", "d", "d");
testRepo.reset(initialHead);
PushOneCommit.Result change4 = createChange("Change 4", "d", "d");
submitStatusOnly(change2.getChangeId());
submitStatusOnly(change3.getChangeId());
@@ -187,9 +186,9 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitDependentNonConflictingChangesOutOfOrder() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b");
PushOneCommit.Result change3 = createChange(git, "Change 3", "c", "c");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b");
PushOneCommit.Result change3 = createChange("Change 3", "c", "c");
assertThat(change3.getCommit().getParent(0)).isEqualTo(change2.getCommit());
// Submit succeeds; change3 is successfully cherry-picked onto head.
@@ -215,9 +214,9 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitDependentConflictingChangesOutOfOrder() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b1");
PushOneCommit.Result change3 = createChange(git, "Change 3", "b", "b2");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b1");
PushOneCommit.Result change3 = createChange("Change 3", "b", "b2");
assertThat(change3.getCommit().getParent(0)).isEqualTo(change2.getCommit());
// Submit fails; change3 contains the delta "b1" -> "b2", which cannot be
@@ -238,11 +237,11 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitSubsetOfDependentChanges() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
createChange(git, "Change 2", "b", "b");
PushOneCommit.Result change3 = createChange(git, "Change 3", "c", "c");
createChange(git, "Change 4", "d", "d");
PushOneCommit.Result change5 = createChange(git, "Change 5", "e", "e");
testRepo.reset(initialHead);
createChange("Change 2", "b", "b");
PushOneCommit.Result change3 = createChange("Change 3", "c", "c");
createChange("Change 4", "d", "d");
PushOneCommit.Result change5 = createChange("Change 5", "e", "e");
// Out of the above, only submit 3 and 5.
submitStatusOnly(change3.getChangeId());
@@ -264,14 +263,14 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
public void submitChangeAfterParentFailsDueToConflict() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b1");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b1");
submit(change2.getChangeId());
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change3 = createChange(git, "Change 3", "b", "b2");
testRepo.reset(initialHead);
PushOneCommit.Result change3 = createChange("Change 3", "b", "b2");
assertThat(change3.getCommit().getParent(0)).isEqualTo(initialHead);
PushOneCommit.Result change4 = createChange(git, "Change 3", "c", "c3");
PushOneCommit.Result change4 = createChange("Change 3", "c", "c3");
submitStatusOnly(change3.getChangeId());
submitStatusOnly(change4.getChangeId());

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.client.SubmitType;
@@ -33,7 +32,7 @@ public class SubmitByFastForwardIT extends AbstractSubmit {
@Test
public void submitWithFastForward() throws Exception {
RevCommit oldHead = getRemoteHead();
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getId()).isEqualTo(change.getCommitId());
@@ -45,13 +44,13 @@ public class SubmitByFastForwardIT extends AbstractSubmit {
public void submitFastForwardNotPossible_Conflict() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "b.txt", "other content");
createChange("Change 2", "b.txt", "other content");
submitWithConflict(change2.getChangeId());
assertThat(getRemoteHead()).isEqualTo(oldHead);
assertSubmitter(change.getChangeId(), 1);

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.client.SubmitType;
@@ -35,7 +34,7 @@ public class SubmitByMergeAlwaysIT extends AbstractSubmitByMerge {
@Test
public void submitWithMergeIfFastForwardPossible() throws Exception {
RevCommit oldHead = getRemoteHead();
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getParentCount()).isEqualTo(2);
@@ -48,14 +47,14 @@ public class SubmitByMergeAlwaysIT extends AbstractSubmitByMerge {
public void submitMultipleChanges() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change3 = createChange(git, "Change 3", "c", "c");
testRepo.reset(initialHead);
PushOneCommit.Result change3 = createChange("Change 3", "c", "c");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change4 = createChange(git, "Change 4", "d", "d");
testRepo.reset(initialHead);
PushOneCommit.Result change4 = createChange("Change 4", "d", "d");
submitStatusOnly(change2.getChangeId());
submitStatusOnly(change3.getChangeId());

View File

@@ -1,7 +1,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.extensions.client.SubmitType;
@@ -21,7 +20,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
@Test
public void submitWithFastForward() throws Exception {
RevCommit oldHead = getRemoteHead();
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getId()).isEqualTo(change.getCommitId());
@@ -33,14 +32,14 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
public void submitMultipleChanges() throws Exception {
RevCommit initialHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change2 = createChange(git, "Change 2", "b", "b");
testRepo.reset(initialHead);
PushOneCommit.Result change2 = createChange("Change 2", "b", "b");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change3 = createChange(git, "Change 3", "c", "c");
testRepo.reset(initialHead);
PushOneCommit.Result change3 = createChange("Change 3", "c", "c");
checkout(git, initialHead.getId().getName());
PushOneCommit.Result change4 = createChange(git, "Change 4", "d", "d");
testRepo.reset(initialHead);
PushOneCommit.Result change4 = createChange("Change 4", "d", "d");
submitStatusOnly(change2.getChangeId());
submitStatusOnly(change3.getChangeId());

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.change;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.TestProjectInput;
@@ -36,7 +35,7 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithFastForward() throws Exception {
RevCommit oldHead = getRemoteHead();
PushOneCommit.Result change = createChange(git);
PushOneCommit.Result change = createChange();
submit(change.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getId()).isEqualTo(change.getCommitId());
@@ -51,13 +50,13 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
public void submitWithRebase() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "b.txt", "other content");
createChange("Change 2", "b.txt", "other content");
submit(change2.getChangeId());
assertRebase(git, false);
RevCommit head = getRemoteHead();
@@ -72,16 +71,16 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "aaa\nbbb\nccc\n");
createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
submit(change.getChangeId());
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
submit(change2.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, change.getCommitId().getName());
testRepo.reset(change.getCommitId());
PushOneCommit.Result change3 =
createChange(git, "Change 3", "a.txt", "bbb\nccc\n");
createChange("Change 3", "a.txt", "bbb\nccc\n");
submit(change3.getChangeId());
assertRebase(git, true);
RevCommit head = getRemoteHead();
@@ -97,13 +96,13 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
public void submitWithContentMerge_Conflict() throws Exception {
RevCommit initialHead = getRemoteHead();
PushOneCommit.Result change =
createChange(git, "Change 1", "a.txt", "content");
createChange("Change 1", "a.txt", "content");
submit(change.getChangeId());
RevCommit oldHead = getRemoteHead();
checkout(git, initialHead.getId().getName());
testRepo.reset(initialHead);
PushOneCommit.Result change2 =
createChange(git, "Change 2", "a.txt", "other content");
createChange("Change 2", "a.txt", "other content");
submitWithConflict(change2.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head).isEqualTo(oldHead);

View File

@@ -99,7 +99,7 @@ public class GetCommitIT extends AbstractDaemonTest {
@Test
public void getOpenChange_Found() throws Exception {
allow(Permission.READ, REGISTERED_USERS, "refs/heads/*");
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), git)
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), testRepo)
.to("refs/for/master");
r.assertOkStatus();
@@ -123,7 +123,7 @@ public class GetCommitIT extends AbstractDaemonTest {
@Test
public void getOpenChange_NotFound() throws Exception {
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), git)
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), testRepo)
.to("refs/for/master");
r.assertOkStatus();
assertNotFound(r.getCommitId());

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.common.truth.Truth.assertThat;
import static com.google.gerrit.acceptance.GitUtil.checkout;
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
import static com.google.gerrit.acceptance.GitUtil.fetch;
@@ -25,6 +24,7 @@ import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.project.ProjectState;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.Config;
import org.junit.Before;
import org.junit.Test;
@@ -33,7 +33,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
@Before
public void setUp() throws Exception {
fetch(git, RefNames.REFS_CONFIG + ":refs/heads/config");
checkout(git, "refs/heads/config");
testRepo.reset("refs/heads/config");
}
@Test
@@ -43,7 +43,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
cfg.setString("s1", null, "k1", "v1");
cfg.setString("s2", "ss", "k2", "v2");
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), git, "Create Project Level Config",
pushFactory.create(db, admin.getIdent(), testRepo, "Create Project Level Config",
configName, cfg.toText());
push.to(RefNames.REFS_CONFIG);
@@ -70,17 +70,19 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
Git parentGit =
cloneProject(sshSession.getUrl() + "/" + allProjects.get(), false);
TestRepository<?> parentTestRepo =
new TestRepository<>(parentGit.getRepository());
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
checkout(parentGit, "refs/heads/config");
parentTestRepo.reset("refs/heads/config");
PushOneCommit push =
pushFactory.create(db, admin.getIdent(), parentGit, "Create Project Level Config",
pushFactory.create(db, admin.getIdent(), parentTestRepo, "Create Project Level Config",
configName, parentCfg.toText());
push.to(RefNames.REFS_CONFIG);
Config cfg = new Config();
cfg.setString("s1", null, "k1", "childValue1");
cfg.setString("s2", "ss", "k3", "childValue2");
push = pushFactory.create(db, admin.getIdent(), git, "Create Project Level Config",
push = pushFactory.create(db, admin.getIdent(), testRepo, "Create Project Level Config",
configName, cfg.toText());
push.to(RefNames.REFS_CONFIG);

View File

@@ -50,14 +50,14 @@ public class TagsIT extends AbstractDaemonTest {
grant(Permission.PUSH, project, "refs/tags/*");
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), testRepo);
push1.setTag(tag1);
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
r1.assertOkStatus();
PushOneCommit.AnnotatedTag tag2 =
new PushOneCommit.AnnotatedTag("v2.0", "annotation", admin.getIdent());
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo);
push2.setTag(tag2);
PushOneCommit.Result r2 = push2.to("refs/for/master%submit");
r2.assertOkStatus();
@@ -86,14 +86,14 @@ public class TagsIT extends AbstractDaemonTest {
grant(Permission.PUSH, project, "refs/tags/*");
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), testRepo);
push1.setTag(tag1);
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
r1.assertOkStatus();
pushTo("refs/heads/hidden");
PushOneCommit.Tag tag2 = new PushOneCommit.Tag("v2.0");
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo);
push2.setTag(tag2);
PushOneCommit.Result r2 = push2.to("refs/for/hidden%submit");
r2.assertOkStatus();
@@ -121,7 +121,7 @@ public class TagsIT extends AbstractDaemonTest {
grant(Permission.PUSH, project, "refs/tags/*");
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), testRepo);
push1.setTag(tag1);
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
r1.assertOkStatus();

View File

@@ -87,7 +87,7 @@ public class CommentsIT extends AbstractDaemonTest {
for (Integer line : lines) {
String file = "file";
String contents = "contents " + line;
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
"first subject", file, contents);
PushOneCommit.Result r = push.to("refs/for/master");
String changeId = r.getChangeId();
@@ -161,7 +161,7 @@ public class CommentsIT extends AbstractDaemonTest {
for (Integer line : lines) {
String file = "file";
String contents = "contents " + line;
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
"first subject", file, contents);
PushOneCommit.Result r = push.to("refs/for/master");
String changeId = r.getChangeId();

View File

@@ -50,7 +50,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
@Test
public void getRelatedNoResult() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PatchSet.Id ps = push.to("refs/for/master").getPatchSetId();
List<ChangeAndCommit> related = getRelated(ps);
assertThat(related).isEmpty();

View File

@@ -127,13 +127,13 @@ public class LabelTypeIT extends AbstractDaemonTest {
String file = "a.txt";
String contents = "contents";
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
"first subject", file, contents);
PushOneCommit.Result r = push.to("refs/for/master");
revision(r).review(ReviewInput.recommend());
assertApproval(r, 1);
push = pushFactory.create(db, admin.getIdent(), git,
push = pushFactory.create(db, admin.getIdent(), testRepo,
"second subject", file, contents, r.getChangeId());
r = push.to("refs/for/master");
assertApproval(r, 0);
@@ -146,13 +146,13 @@ public class LabelTypeIT extends AbstractDaemonTest {
codeReview.setCopyAllScoresIfNoCodeChange(true);
saveLabelConfig();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
"first subject", file, contents);
PushOneCommit.Result r = push.to("refs/for/master");
revision(r).review(ReviewInput.recommend());
assertApproval(r, 1);
push = pushFactory.create(db, admin.getIdent(), git,
push = pushFactory.create(db, admin.getIdent(), testRepo,
"second subject", file, contents, r.getChangeId());
r = push.to("refs/for/master");
assertApproval(r, 1);
@@ -164,17 +164,17 @@ public class LabelTypeIT extends AbstractDaemonTest {
String file = "a.txt";
String contents = "contents";
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
merge(r1);
push = pushFactory.create(db, admin.getIdent(), git,
push = pushFactory.create(db, admin.getIdent(), testRepo,
"non-conflicting", "b.txt", "other contents");
PushOneCommit.Result r2 = push.to("refs/for/master");
merge(r2);
git.checkout().setName(r1.getCommit().name()).call();
push = pushFactory.create(db, admin.getIdent(), git, subject, file, contents);
push = pushFactory.create(db, admin.getIdent(), testRepo, subject, file, contents);
PushOneCommit.Result r3 = push.to("refs/for/master");
revision(r3).review(ReviewInput.recommend());
assertApproval(r3, 1);
@@ -191,17 +191,17 @@ public class LabelTypeIT extends AbstractDaemonTest {
codeReview.setCopyAllScoresOnTrivialRebase(true);
saveLabelConfig();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
merge(r1);
push = pushFactory.create(db, admin.getIdent(), git,
push = pushFactory.create(db, admin.getIdent(), testRepo,
"non-conflicting", "b.txt", "other contents");
PushOneCommit.Result r2 = push.to("refs/for/master");
merge(r2);
git.checkout().setName(r1.getCommit().name()).call();
push = pushFactory.create(db, admin.getIdent(), git, subject, file, contents);
push = pushFactory.create(db, admin.getIdent(), testRepo, subject, file, contents);
PushOneCommit.Result r3 = push.to("refs/for/master");
revision(r3).review(ReviewInput.recommend());
assertApproval(r3, 1);
@@ -218,7 +218,7 @@ public class LabelTypeIT extends AbstractDaemonTest {
PushOneCommit.Result r1 = createChange();
git.checkout().setName(r1.getCommit().name()).call();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, "b.txt", "other contents");
PushOneCommit.Result r2 = push.to("refs/for/master");
@@ -248,7 +248,7 @@ public class LabelTypeIT extends AbstractDaemonTest {
git.checkout().setName(r1.getCommit().name()).call();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo,
PushOneCommit.SUBJECT, "b.txt", "other contents");
PushOneCommit.Result r2 = push.to("refs/for/master");