Use TestRepository's Git and Repository in acceptance tests
Avoid storing two references that have to be kept in sync, now that a Git is available directly from TestRepository. Use a git() convenience method to AbstractDaemonTest to shorten this. Similarly, add a repo() convenience method to get the Repository. Change-Id: I1ec8af8fead0876a2836f7972b5caf603847b25d
This commit is contained in:
@@ -64,6 +64,7 @@ import org.apache.http.HttpStatus;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -127,8 +128,7 @@ public abstract class AbstractDaemonTest {
|
||||
@Inject
|
||||
protected @GerritServerConfig Config cfg;
|
||||
|
||||
protected Git git;
|
||||
protected TestRepository<?> testRepo;
|
||||
protected TestRepository<InMemoryRepository> testRepo;
|
||||
protected GerritServer server;
|
||||
protected TestAccount admin;
|
||||
protected TestAccount user;
|
||||
@@ -211,7 +211,7 @@ public abstract class AbstractDaemonTest {
|
||||
project = new Project.NameKey(projectInput.name);
|
||||
createProject(projectInput);
|
||||
|
||||
setRepo(cloneProject(project, sshSession));
|
||||
testRepo = cloneProject(project, sshSession);
|
||||
}
|
||||
|
||||
private ProjectInput projectInput(Description description) {
|
||||
@@ -237,9 +237,12 @@ public abstract class AbstractDaemonTest {
|
||||
return in;
|
||||
}
|
||||
|
||||
protected void setRepo(TestRepository<?> testRepo) throws Exception {
|
||||
this.git = Git.wrap(testRepo.getRepository());
|
||||
this.testRepo = new TestRepository<>(git.getRepository());
|
||||
protected Git git() {
|
||||
return testRepo.git();
|
||||
}
|
||||
|
||||
protected InMemoryRepository repo() {
|
||||
return testRepo.getRepository();
|
||||
}
|
||||
|
||||
protected void createProject(String name) throws RestApiException {
|
||||
@@ -291,7 +294,7 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
|
||||
protected TestRepository<?>.CommitBuilder amendBuilder() throws Exception {
|
||||
ObjectId head = testRepo.getRepository().getRef("HEAD").getObjectId();
|
||||
ObjectId head = repo().getRef("HEAD").getObjectId();
|
||||
TestRepository<?>.CommitBuilder b = testRepo.amendRef("HEAD");
|
||||
Optional<String> id = GitUtil.getChangeId(testRepo, head);
|
||||
// TestRepository behaves like "git commit --amend -m foo", which does not
|
||||
|
@@ -24,7 +24,6 @@ import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
import org.eclipse.jgit.api.FetchCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.PushCommand;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
|
||||
@@ -96,20 +95,21 @@ public class GitUtil {
|
||||
return cloneProject(project, sshSession.getUrl() + "/" + project.get());
|
||||
}
|
||||
|
||||
public static void fetch(Git git, String spec) throws GitAPIException {
|
||||
FetchCommand fetch = git.fetch();
|
||||
public static void fetch(TestRepository<?> testRepo, String spec)
|
||||
throws GitAPIException {
|
||||
FetchCommand fetch = testRepo.git().fetch();
|
||||
fetch.setRefSpecs(new RefSpec(spec));
|
||||
fetch.call();
|
||||
}
|
||||
|
||||
public static PushResult pushHead(Git git, String ref, boolean pushTags)
|
||||
throws GitAPIException {
|
||||
return pushHead(git, ref, pushTags, false);
|
||||
public static PushResult pushHead(TestRepository<?> testRepo, String ref,
|
||||
boolean pushTags) throws GitAPIException {
|
||||
return pushHead(testRepo, ref, pushTags, false);
|
||||
}
|
||||
|
||||
public static PushResult pushHead(Git git, String ref, boolean pushTags,
|
||||
boolean force) throws GitAPIException {
|
||||
PushCommand pushCmd = git.push();
|
||||
public static PushResult pushHead(TestRepository<?> testRepo, String ref,
|
||||
boolean pushTags, boolean force) throws GitAPIException {
|
||||
PushCommand pushCmd = testRepo.git().push();
|
||||
pushCmd.setForce(force);
|
||||
pushCmd.setRefSpecs(new RefSpec("HEAD:" + ref));
|
||||
if (pushTags) {
|
||||
|
@@ -36,7 +36,6 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.TagCommand;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -181,9 +180,8 @@ public class PushOneCommit {
|
||||
if (changeId == null) {
|
||||
changeId = GitUtil.getChangeId(testRepo, c).get();
|
||||
}
|
||||
Git git = Git.wrap(testRepo.getRepository());
|
||||
if (tag != null) {
|
||||
TagCommand tagCommand = git.tag().setName(tag.name);
|
||||
TagCommand tagCommand = testRepo.git().tag().setName(tag.name);
|
||||
if (tag instanceof AnnotatedTag) {
|
||||
AnnotatedTag annotatedTag = (AnnotatedTag)tag;
|
||||
tagCommand.setAnnotated(true)
|
||||
@@ -194,7 +192,8 @@ public class PushOneCommit {
|
||||
}
|
||||
tagCommand.call();
|
||||
}
|
||||
return new Result(ref, pushHead(git, ref, tag != null, force), c, subject);
|
||||
return new Result(ref, pushHead(testRepo, ref, tag != null, force), c,
|
||||
subject);
|
||||
}
|
||||
|
||||
public void setTag(final Tag tag) {
|
||||
|
@@ -349,7 +349,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void mergeable() throws Exception {
|
||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT,
|
||||
@@ -360,7 +360,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
merge(r1);
|
||||
|
||||
// Reset HEAD to initial so the new change is a merge conflict.
|
||||
RefUpdate ru = git.getRepository().updateRef(HEAD);
|
||||
RefUpdate ru = repo().updateRef(HEAD);
|
||||
ru.setNewObjectId(initial);
|
||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||
|
||||
|
@@ -68,7 +68,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
default:
|
||||
throw new IllegalArgumentException("unexpected protocol: " + p);
|
||||
}
|
||||
setRepo(cloneProject(project, url + "/" + project.get()));
|
||||
testRepo = cloneProject(project, url + "/" + project.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -29,14 +29,14 @@ public class ForcePushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void forcePushNotAllowed() throws Exception {
|
||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
||||
r1.assertOkStatus();
|
||||
|
||||
// Reset HEAD to initial so the new change is a non-fast forward
|
||||
RefUpdate ru = git.getRepository().updateRef(HEAD);
|
||||
RefUpdate ru = repo().updateRef(HEAD);
|
||||
ru.setNewObjectId(initial);
|
||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void forcePushAllowed() throws Exception {
|
||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||
ObjectId initial = repo().getRef(HEAD).getLeaf().getObjectId();
|
||||
grant(Permission.PUSH, project, "refs/*", true);
|
||||
PushOneCommit push1 =
|
||||
pushFactory.create(db, admin.getIdent(), testRepo, "change1", "a.txt", "content");
|
||||
@@ -57,7 +57,7 @@ public class ForcePushIT extends AbstractDaemonTest {
|
||||
r1.assertOkStatus();
|
||||
|
||||
// Reset HEAD to initial so the new change is a non-fast forward
|
||||
RefUpdate ru = git.getRepository().updateRef(HEAD);
|
||||
RefUpdate ru = repo().updateRef(HEAD);
|
||||
ru.setNewObjectId(initial);
|
||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||
|
||||
|
@@ -103,9 +103,8 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
public void submitOnPushToRefsMetaConfig() throws Exception {
|
||||
grant(Permission.SUBMIT, project, "refs/for/refs/meta/config");
|
||||
|
||||
git.fetch().setRefSpecs(new RefSpec("refs/meta/config:refs/meta/config")).call();
|
||||
ObjectId objectId = git.getRepository().getRef("refs/meta/config").getObjectId();
|
||||
testRepo.reset(objectId);
|
||||
git().fetch().setRefSpecs(new RefSpec("refs/meta/config:refs/meta/config")).call();
|
||||
testRepo.reset("refs/meta/config");
|
||||
|
||||
PushOneCommit.Result r = pushTo("refs/for/refs/meta/config%submit");
|
||||
r.assertOkStatus();
|
||||
@@ -116,7 +115,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void submitOnPushMergeConflict() throws Exception {
|
||||
ObjectId objectId = git.getRepository().getRef("HEAD").getObjectId();
|
||||
ObjectId objectId = repo().getRef("HEAD").getObjectId();
|
||||
push("refs/heads/master", "one change", "a.txt", "some content");
|
||||
testRepo.reset(objectId);
|
||||
|
||||
@@ -131,7 +130,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void submitOnPushSuccessfulMerge() throws Exception {
|
||||
String master = "refs/heads/master";
|
||||
ObjectId objectId = git.getRepository().getRef("HEAD").getObjectId();
|
||||
ObjectId objectId = repo().getRef("HEAD").getObjectId();
|
||||
push(master, "one change", "a.txt", "some content");
|
||||
testRepo.reset(objectId);
|
||||
|
||||
@@ -196,7 +195,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
||||
push("refs/for/master", PushOneCommit.SUBJECT, "a.txt", "some content");
|
||||
r.assertOkStatus();
|
||||
|
||||
git.push()
|
||||
git().push()
|
||||
.setRefSpecs(new RefSpec(r.getCommitId().name() + ":refs/heads/master"))
|
||||
.call();
|
||||
assertCommit(project, "refs/heads/master");
|
||||
|
@@ -57,8 +57,8 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.diff.DiffFormatter;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
@@ -279,17 +279,17 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
assertThat(submitter.getAccountId()).isEqualTo(admin.getId());
|
||||
}
|
||||
|
||||
protected void assertCherryPick(Git localGit, boolean contentMerge)
|
||||
throws IOException {
|
||||
assertRebase(localGit, contentMerge);
|
||||
protected void assertCherryPick(TestRepository<?> testRepo,
|
||||
boolean contentMerge) throws IOException {
|
||||
assertRebase(testRepo, contentMerge);
|
||||
RevCommit remoteHead = getRemoteHead();
|
||||
assertThat(remoteHead.getFooterLines("Reviewed-On")).isNotEmpty();
|
||||
assertThat(remoteHead.getFooterLines("Reviewed-By")).isNotEmpty();
|
||||
}
|
||||
|
||||
protected void assertRebase(Git localGit, boolean contentMerge)
|
||||
protected void assertRebase(TestRepository<?> testRepo, boolean contentMerge)
|
||||
throws IOException {
|
||||
Repository repo = localGit.getRepository();
|
||||
Repository repo = testRepo.getRepository();
|
||||
RevCommit localHead = getHead(repo);
|
||||
RevCommit remoteHead = getRemoteHead();
|
||||
assert_().withFailureMessage(
|
||||
|
@@ -53,7 +53,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
SshSession sshSession = new SshSession(server, user);
|
||||
initSsh(user);
|
||||
sshSession.open();
|
||||
setRepo(cloneProject(project, sshSession));
|
||||
testRepo = cloneProject(project, sshSession);
|
||||
sshSession.close();
|
||||
user2 = accounts.user2();
|
||||
sessionDev = new RestSession(server, user2);
|
||||
|
@@ -41,7 +41,7 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
public void submitWithCherryPickIfFastForwardPossible() throws Exception {
|
||||
PushOneCommit.Result change = createChange();
|
||||
submit(change.getChangeId());
|
||||
assertCherryPick(git, false);
|
||||
assertCherryPick(testRepo, false);
|
||||
assertThat(getRemoteHead().getParent(0))
|
||||
.isEqualTo(change.getCommit().getParent(0));
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change2 =
|
||||
createChange("Change 2", "b.txt", "other content");
|
||||
submit(change2.getChangeId());
|
||||
assertCherryPick(git, false);
|
||||
assertCherryPick(testRepo, false);
|
||||
RevCommit newHead = getRemoteHead();
|
||||
assertThat(newHead.getParentCount()).isEqualTo(1);
|
||||
assertThat(newHead.getParent(0)).isEqualTo(oldHead);
|
||||
@@ -82,7 +82,7 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change3 =
|
||||
createChange("Change 3", "a.txt", "bbb\nccc\n");
|
||||
submit(change3.getChangeId());
|
||||
assertCherryPick(git, true);
|
||||
assertCherryPick(testRepo, true);
|
||||
RevCommit newHead = getRemoteHead();
|
||||
assertThat(newHead.getParent(0)).isEqualTo(oldHead);
|
||||
assertApproved(change3.getChangeId());
|
||||
@@ -122,7 +122,7 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change3 =
|
||||
createChange("Change 3", "c.txt", "different content");
|
||||
submit(change3.getChangeId());
|
||||
assertCherryPick(git, false);
|
||||
assertCherryPick(testRepo, false);
|
||||
RevCommit newHead = getRemoteHead();
|
||||
assertThat(newHead.getParent(0)).isEqualTo(oldHead);
|
||||
assertApproved(change3.getChangeId());
|
||||
|
@@ -58,7 +58,7 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change2 =
|
||||
createChange("Change 2", "b.txt", "other content");
|
||||
submit(change2.getChangeId());
|
||||
assertRebase(git, false);
|
||||
assertRebase(testRepo, false);
|
||||
RevCommit head = getRemoteHead();
|
||||
assertThat(head.getParent(0)).isEqualTo(oldHead);
|
||||
assertApproved(change2.getChangeId());
|
||||
@@ -82,7 +82,7 @@ public class SubmitByRebaseIfNecessaryIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change3 =
|
||||
createChange("Change 3", "a.txt", "bbb\nccc\n");
|
||||
submit(change3.getChangeId());
|
||||
assertRebase(git, true);
|
||||
assertRebase(testRepo, true);
|
||||
RevCommit head = getRemoteHead();
|
||||
assertThat(head.getParent(0)).isEqualTo(oldHead);
|
||||
assertApproved(change3.getChangeId());
|
||||
|
@@ -45,7 +45,7 @@ public class BanCommitIT extends AbstractDaemonTest {
|
||||
assertThat(info.alreadyBanned).isNull();
|
||||
assertThat(info.ignored).isNull();
|
||||
|
||||
PushResult pushResult = pushHead(git, "refs/heads/master", false);
|
||||
PushResult pushResult = pushHead(testRepo, "refs/heads/master", false);
|
||||
assertThat(pushResult.getRemoteUpdate("refs/heads/master").getMessage())
|
||||
.startsWith("contains banned commit");
|
||||
}
|
||||
|
@@ -61,9 +61,9 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listBranches() throws Exception {
|
||||
pushTo("refs/heads/master");
|
||||
String headCommit = git.getRepository().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
String headCommit = repo().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
pushTo("refs/heads/dev");
|
||||
String devCommit = git.getRepository().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
String devCommit = repo().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
RestResponse r = adminSession.get("/projects/" + project.get() + "/branches");
|
||||
List<BranchInfo> expected = Lists.asList(
|
||||
new BranchInfo("refs/meta/config", null, false),
|
||||
@@ -86,7 +86,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
public void listBranchesSomeHidden() throws Exception {
|
||||
blockRead(project, "refs/heads/dev");
|
||||
pushTo("refs/heads/master");
|
||||
String headCommit = git.getRepository().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
String headCommit = repo().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
pushTo("refs/heads/dev");
|
||||
RestResponse r = userSession.get("/projects/" + project.get() + "/branches");
|
||||
// refs/meta/config is hidden since user is no project owner
|
||||
@@ -103,7 +103,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
blockRead(project, "refs/heads/master");
|
||||
pushTo("refs/heads/master");
|
||||
pushTo("refs/heads/dev");
|
||||
String devCommit = git.getRepository().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
String devCommit = repo().getRef("HEAD").getTarget().getObjectId().getName();
|
||||
RestResponse r = userSession.get("/projects/" + project.get() + "/branches");
|
||||
// refs/meta/config is hidden since user is no project owner
|
||||
assertBranches(Collections.singletonList(new BranchInfo("refs/heads/dev",
|
||||
|
@@ -23,7 +23,6 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
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;
|
||||
@@ -32,7 +31,7 @@ import org.junit.Test;
|
||||
public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
fetch(git, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
fetch(testRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
testRepo.reset("refs/heads/config");
|
||||
}
|
||||
|
||||
@@ -69,8 +68,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
parentCfg.setString("s2", "ss", "k4", "parentValue4");
|
||||
|
||||
TestRepository<?> parentTestRepo = cloneProject(allProjects, sshSession);
|
||||
Git parentGit = Git.wrap(parentTestRepo.getRepository());
|
||||
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
fetch(parentTestRepo, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||
parentTestRepo.reset("refs/heads/config");
|
||||
PushOneCommit push =
|
||||
pushFactory.create(db, admin.getIdent(), parentTestRepo, "Create Project Level Config",
|
||||
|
@@ -67,7 +67,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
.message("subject: 2")
|
||||
.create();
|
||||
String id2 = getChangeId(testRepo, c2).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
for (RevCommit c : ImmutableList.of(c2, c1)) {
|
||||
List<ChangeAndCommit> related = getRelated(getPatchSetId(c));
|
||||
@@ -93,7 +93,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
.message("subject: 2")
|
||||
.create();
|
||||
String id2 = getChangeId(testRepo, c2).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
PatchSet.Id c1ps1 = getPatchSetId(c1);
|
||||
PatchSet.Id c2ps1 = getPatchSetId(c2);
|
||||
|
||||
@@ -101,7 +101,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
testRepo.reset("HEAD~2");
|
||||
testRepo.cherryPick(c2);
|
||||
testRepo.cherryPick(c1);
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
PatchSet.Id c1ps2 = getPatchSetId(c1);
|
||||
PatchSet.Id c2ps2 = getPatchSetId(c2);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void getRelatedReorderAndExtend() throws Exception {
|
||||
// Create two commits and push.
|
||||
ObjectId initial = testRepo.getRepository().getRef("HEAD").getObjectId();
|
||||
ObjectId initial = repo().getRef("HEAD").getObjectId();
|
||||
RevCommit c1 = commitBuilder()
|
||||
.add("a.txt", "1")
|
||||
.message("subject: 1")
|
||||
@@ -138,7 +138,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
.message("subject: 2")
|
||||
.create();
|
||||
String id2 = getChangeId(testRepo, c2).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
PatchSet.Id c1ps1 = getPatchSetId(c1);
|
||||
PatchSet.Id c2ps1 = getPatchSetId(c2);
|
||||
|
||||
@@ -151,7 +151,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
.message("subject: 3")
|
||||
.create();
|
||||
String id3 = getChangeId(testRepo, c3).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
PatchSet.Id c1ps2 = getPatchSetId(c1);
|
||||
PatchSet.Id c2ps2 = getPatchSetId(c2);
|
||||
PatchSet.Id c3ps1 = getPatchSetId(c3);
|
||||
@@ -197,7 +197,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
||||
.message("subject: 3")
|
||||
.create();
|
||||
String id3 = getChangeId(testRepo, c3).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
Change ch2 = getChange(c2).change();
|
||||
editModifier.createEdit(ch2, getPatchSet(ch2));
|
||||
|
@@ -55,7 +55,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_D, "4")
|
||||
.message(SUBJECT_1)
|
||||
.create();
|
||||
pushHead(git, "refs/heads/master", false);
|
||||
pushHead(testRepo, "refs/heads/master", false);
|
||||
|
||||
// Change 1, 1 (+FILE_A, -FILE_D)
|
||||
RevCommit c = commitBuilder()
|
||||
@@ -65,7 +65,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.insertChangeId()
|
||||
.create();
|
||||
String id = getChangeId(testRepo, c).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Compare Change 1,1 with Base (+FILE_A, -FILE_D)
|
||||
List<PatchListEntry> entries = getCurrentPatches(id);
|
||||
@@ -78,7 +78,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
c = amendBuilder()
|
||||
.add(FILE_B, "2")
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
entries = getCurrentPatches(id);
|
||||
|
||||
// Compare Change 1,2 with Base (+FILE_A, +FILE_B, -FILE_D)
|
||||
@@ -95,7 +95,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_D, "4")
|
||||
.message(SUBJECT_1)
|
||||
.create();
|
||||
pushHead(git, "refs/heads/master", false);
|
||||
pushHead(testRepo, "refs/heads/master", false);
|
||||
|
||||
// Change 1,1 (+FILE_A, -FILE_D)
|
||||
RevCommit c = commitBuilder()
|
||||
@@ -104,7 +104,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.message(SUBJECT_2)
|
||||
.create();
|
||||
String id = getChangeId(testRepo, c).get();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
List<PatchListEntry> entries = getCurrentPatches(id);
|
||||
assertThat(entries).hasSize(3);
|
||||
assertAdded(Patch.COMMIT_MSG, entries.get(0));
|
||||
@@ -117,11 +117,11 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_B, "2")
|
||||
.message(SUBJECT_3)
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Change 1,2 (+FILE_A, -FILE_D))
|
||||
testRepo.cherryPick(c);
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Compare Change 1,2 with Base (+FILE_A, -FILE_D))
|
||||
entries = getCurrentPatches(id);
|
||||
@@ -137,7 +137,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_D, "4")
|
||||
.message(SUBJECT_1)
|
||||
.create();
|
||||
pushHead(git, "refs/heads/master", false);
|
||||
pushHead(testRepo, "refs/heads/master", false);
|
||||
|
||||
// Change 1,1 (+FILE_A, +FILE_C, -FILE_D)
|
||||
RevCommit a = commitBuilder()
|
||||
@@ -146,14 +146,14 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.rm(FILE_D)
|
||||
.message(SUBJECT_2)
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Change 1,2 (+FILE_A, +FILE_B, -FILE_D)
|
||||
RevCommit b = amendBuilder()
|
||||
.add(FILE_B, "2")
|
||||
.rm(FILE_C)
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Compare Change 1,1 with Change 1,2 (+FILE_B)
|
||||
List<PatchListEntry> entries = getPatches(a, b);
|
||||
@@ -168,7 +168,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_D, "4")
|
||||
.message(SUBJECT_1)
|
||||
.create();
|
||||
pushHead(git, "refs/heads/master", false);
|
||||
pushHead(testRepo, "refs/heads/master", false);
|
||||
|
||||
// Change 1,1 (+FILE_A, -FILE_D)
|
||||
RevCommit a = commitBuilder()
|
||||
@@ -176,7 +176,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.rm(FILE_D)
|
||||
.message(SUBJECT_2)
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Change 2,1 (+FILE_B)
|
||||
testRepo.reset("HEAD~1");
|
||||
@@ -184,14 +184,14 @@ public class PatchListCacheIT extends AbstractDaemonTest {
|
||||
.add(FILE_B, "2")
|
||||
.message(SUBJECT_3)
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Change 1,2 (+FILE_A, +FILE_C, -FILE_D)
|
||||
testRepo.cherryPick(a);
|
||||
RevCommit b = amendBuilder()
|
||||
.add(FILE_C, "2")
|
||||
.create();
|
||||
pushHead(git, "refs/for/master", false);
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
// Compare Change 1,1 with Change 1,2 (+FILE_C)
|
||||
List<PatchListEntry> entries = getPatches(a, b);
|
||||
|
@@ -42,7 +42,7 @@ public class BanCommitIT extends AbstractDaemonTest {
|
||||
.that(sshSession.hasError()).isFalse();
|
||||
assertThat(response.toLowerCase(Locale.US)).doesNotContain("error");
|
||||
|
||||
PushResult pushResult = pushHead(git, "refs/heads/master", false);
|
||||
PushResult pushResult = pushHead(testRepo, "refs/heads/master", false);
|
||||
assertThat(pushResult.getRemoteUpdate("refs/heads/master").getMessage())
|
||||
.startsWith("contains banned commit");
|
||||
}
|
||||
|
Reference in New Issue
Block a user