PushOneCommit: Move Git into constructor
It makes no sense to make multiple method calls on a single PushOneCommit instance passing in different repositories each time. Pass a single instance into the factory method instead. Change-Id: I718aa01c9090bb0394c70626515693c37d3b8125
This commit is contained in:
committed by
David Pursehouse
parent
e6992e76f6
commit
b074c9f74f
@@ -277,8 +277,8 @@ public abstract class AbstractDaemonTest {
|
|||||||
|
|
||||||
protected PushOneCommit.Result createChange() throws GitAPIException,
|
protected PushOneCommit.Result createChange() throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
return push.to(git, "refs/for/master");
|
return push.to("refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final List<Character> RANDOM =
|
private static final List<Character> RANDOM =
|
||||||
@@ -292,9 +292,9 @@ public abstract class AbstractDaemonTest {
|
|||||||
throws GitAPIException, IOException {
|
throws GitAPIException, IOException {
|
||||||
Collections.shuffle(RANDOM);
|
Collections.shuffle(RANDOM);
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
PushOneCommit.FILE_NAME, new String(Chars.toArray(RANDOM)), changeId);
|
PushOneCommit.FILE_NAME, new String(Chars.toArray(RANDOM)), changeId);
|
||||||
return push.to(git, ref);
|
return push.to(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ChangeInfo getChange(String changeId, ListChangesOption... options)
|
protected ChangeInfo getChange(String changeId, ListChangesOption... options)
|
||||||
@@ -416,7 +416,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
|
|
||||||
protected PushOneCommit.Result pushTo(String ref) throws GitAPIException,
|
protected PushOneCommit.Result pushTo(String ref) throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
return push.to(git, ref);
|
return push.to(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,11 +65,13 @@ public class PushOneCommit {
|
|||||||
public interface Factory {
|
public interface Factory {
|
||||||
PushOneCommit create(
|
PushOneCommit create(
|
||||||
ReviewDb db,
|
ReviewDb db,
|
||||||
PersonIdent i);
|
PersonIdent i,
|
||||||
|
Git git);
|
||||||
|
|
||||||
PushOneCommit create(
|
PushOneCommit create(
|
||||||
ReviewDb db,
|
ReviewDb db,
|
||||||
PersonIdent i,
|
PersonIdent i,
|
||||||
|
Git git,
|
||||||
@Assisted("subject") String subject,
|
@Assisted("subject") String subject,
|
||||||
@Assisted("fileName") String fileName,
|
@Assisted("fileName") String fileName,
|
||||||
@Assisted("content") String content);
|
@Assisted("content") String content);
|
||||||
@@ -77,6 +79,7 @@ public class PushOneCommit {
|
|||||||
PushOneCommit create(
|
PushOneCommit create(
|
||||||
ReviewDb db,
|
ReviewDb db,
|
||||||
PersonIdent i,
|
PersonIdent i,
|
||||||
|
Git git,
|
||||||
@Assisted("subject") String subject,
|
@Assisted("subject") String subject,
|
||||||
@Assisted("fileName") String fileName,
|
@Assisted("fileName") String fileName,
|
||||||
@Assisted("content") String content,
|
@Assisted("content") String content,
|
||||||
@@ -107,6 +110,7 @@ public class PushOneCommit {
|
|||||||
private final Provider<InternalChangeQuery> queryProvider;
|
private final Provider<InternalChangeQuery> queryProvider;
|
||||||
private final ReviewDb db;
|
private final ReviewDb db;
|
||||||
private final PersonIdent i;
|
private final PersonIdent i;
|
||||||
|
private final Git git;
|
||||||
|
|
||||||
private final String subject;
|
private final String subject;
|
||||||
private final String fileName;
|
private final String fileName;
|
||||||
@@ -120,9 +124,10 @@ public class PushOneCommit {
|
|||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
Provider<InternalChangeQuery> queryProvider,
|
Provider<InternalChangeQuery> queryProvider,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted PersonIdent i) {
|
@Assisted PersonIdent i,
|
||||||
|
@Assisted Git git) {
|
||||||
this(notesFactory, approvalsUtil, queryProvider,
|
this(notesFactory, approvalsUtil, queryProvider,
|
||||||
db, i, SUBJECT, FILE_NAME, FILE_CONTENT);
|
db, i, git, SUBJECT, FILE_NAME, FILE_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssistedInject
|
@AssistedInject
|
||||||
@@ -131,11 +136,12 @@ public class PushOneCommit {
|
|||||||
Provider<InternalChangeQuery> queryProvider,
|
Provider<InternalChangeQuery> queryProvider,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted PersonIdent i,
|
@Assisted PersonIdent i,
|
||||||
|
@Assisted Git git,
|
||||||
@Assisted("subject") String subject,
|
@Assisted("subject") String subject,
|
||||||
@Assisted("fileName") String fileName,
|
@Assisted("fileName") String fileName,
|
||||||
@Assisted("content") String content) {
|
@Assisted("content") String content) {
|
||||||
this(notesFactory, approvalsUtil, queryProvider,
|
this(notesFactory, approvalsUtil, queryProvider,
|
||||||
db, i, subject, fileName, content, null);
|
db, i, git, subject, fileName, content, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssistedInject
|
@AssistedInject
|
||||||
@@ -144,6 +150,7 @@ public class PushOneCommit {
|
|||||||
Provider<InternalChangeQuery> queryProvider,
|
Provider<InternalChangeQuery> queryProvider,
|
||||||
@Assisted ReviewDb db,
|
@Assisted ReviewDb db,
|
||||||
@Assisted PersonIdent i,
|
@Assisted PersonIdent i,
|
||||||
|
@Assisted Git git,
|
||||||
@Assisted("subject") String subject,
|
@Assisted("subject") String subject,
|
||||||
@Assisted("fileName") String fileName,
|
@Assisted("fileName") String fileName,
|
||||||
@Assisted("content") String content,
|
@Assisted("content") String content,
|
||||||
@@ -153,23 +160,24 @@ public class PushOneCommit {
|
|||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.queryProvider = queryProvider;
|
this.queryProvider = queryProvider;
|
||||||
this.i = i;
|
this.i = i;
|
||||||
|
this.git = git;
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.changeId = changeId;
|
this.changeId = changeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result to(Git git, String ref) throws GitAPIException, IOException {
|
public Result to(String ref) throws GitAPIException, IOException {
|
||||||
add(git, fileName, content);
|
add(git, fileName, content);
|
||||||
return execute(git, ref);
|
return execute(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result rm(Git git, String ref) throws GitAPIException {
|
public Result rm(String ref) throws GitAPIException {
|
||||||
GitUtil.rm(git, fileName);
|
GitUtil.rm(git, fileName);
|
||||||
return execute(git, ref);
|
return execute(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Result execute(Git git, String ref) throws GitAPIException,
|
private Result execute(String ref) throws GitAPIException,
|
||||||
ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException {
|
ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException {
|
||||||
Commit c;
|
Commit c;
|
||||||
if (changeId != null) {
|
if (changeId != null) {
|
||||||
|
|||||||
@@ -214,9 +214,9 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
String subject = "Test change\n\n" +
|
String subject = "Test change\n\n" +
|
||||||
"Change-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
"Change-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), subject,
|
pushFactory.create(db, admin.getIdent(), git, subject,
|
||||||
"another_file.txt", "another content");
|
"another_file.txt", "another content");
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
|
|
||||||
// Change 2's parent should be change 1
|
// Change 2's parent should be change 1
|
||||||
assertThat(r2.getCommit().getParents()[0].name())
|
assertThat(r2.getCommit().getParents()[0].name())
|
||||||
@@ -283,9 +283,9 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
.create(new BranchInput());
|
.create(new BranchInput());
|
||||||
|
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
PushOneCommit.FILE_NAME, "another content");
|
PushOneCommit.FILE_NAME, "another content");
|
||||||
push.to(git, "refs/heads/foo");
|
push.to("refs/heads/foo");
|
||||||
|
|
||||||
ChangeApi orig = gApi.changes().id("p~master~" + r.getChangeId());
|
ChangeApi orig = gApi.changes().id("p~master~" + r.getChangeId());
|
||||||
assertThat((Iterable<?>)orig.get().messages).hasSize(1);
|
assertThat((Iterable<?>)orig.get().messages).hasSize(1);
|
||||||
@@ -300,12 +300,12 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void canRebase() throws Exception {
|
public void canRebase() throws Exception {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r1 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r1 = push.to("refs/for/master");
|
||||||
merge(r1);
|
merge(r1);
|
||||||
|
|
||||||
push = pushFactory.create(db, admin.getIdent());
|
push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
boolean canRebase = gApi.changes()
|
boolean canRebase = gApi.changes()
|
||||||
.id(r2.getChangeId())
|
.id(r2.getChangeId())
|
||||||
.revision(r2.getCommit().name())
|
.revision(r2.getCommit().name())
|
||||||
@@ -314,8 +314,8 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
merge(r2);
|
merge(r2);
|
||||||
|
|
||||||
git.checkout().setName(r1.getCommit().name()).call();
|
git.checkout().setName(r1.getCommit().name()).call();
|
||||||
push = pushFactory.create(db, admin.getIdent());
|
push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r3 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r3 = push.to("refs/for/master");
|
||||||
|
|
||||||
canRebase = gApi.changes()
|
canRebase = gApi.changes()
|
||||||
.id(r3.getChangeId())
|
.id(r3.getChangeId())
|
||||||
@@ -326,8 +326,8 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setUnsetReviewedFlag() throws Exception {
|
public void setUnsetReviewedFlag() throws Exception {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
|
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(r.getChangeId())
|
.id(r.getChangeId())
|
||||||
@@ -354,10 +354,10 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||||
|
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
PushOneCommit.FILE_NAME, "push 1 content");
|
PushOneCommit.FILE_NAME, "push 1 content");
|
||||||
|
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/for/master");
|
PushOneCommit.Result r1 = push1.to("refs/for/master");
|
||||||
assertMergeable(r1.getChangeId(), true);
|
assertMergeable(r1.getChangeId(), true);
|
||||||
merge(r1);
|
merge(r1);
|
||||||
|
|
||||||
@@ -367,9 +367,9 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||||
|
|
||||||
PushOneCommit push2 =
|
PushOneCommit push2 =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
PushOneCommit.FILE_NAME, "push 2 content");
|
PushOneCommit.FILE_NAME, "push 2 content");
|
||||||
PushOneCommit.Result r2 = push2.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push2.to("refs/for/master");
|
||||||
assertMergeable(r2.getChangeId(), false);
|
assertMergeable(r2.getChangeId(), false);
|
||||||
// TODO(dborowitz): Test for other-branches.
|
// TODO(dborowitz): Test for other-branches.
|
||||||
}
|
}
|
||||||
@@ -522,14 +522,14 @@ public class RevisionIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private PushOneCommit.Result updateChange(PushOneCommit.Result r,
|
private PushOneCommit.Result updateChange(PushOneCommit.Result r,
|
||||||
String content) throws GitAPIException, IOException {
|
String content) throws GitAPIException, IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"test commit", "a.txt", content, r.getChangeId());
|
"test commit", "a.txt", content, r.getChangeId());
|
||||||
return push.to(git, "refs/for/master");
|
return push.to("refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
private PushOneCommit.Result createDraft() throws GitAPIException,
|
private PushOneCommit.Result createDraft() throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
return push.to(git, "refs/drafts/master");
|
return push.to("refs/drafts/master");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -244,9 +244,9 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
|||||||
assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
|
assertThat(edit.getBasePatchSet().getPatchSetId()).isEqualTo(
|
||||||
current.getPatchSetId());
|
current.getPatchSetId());
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT, FILE_NAME,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT, FILE_NAME,
|
||||||
new String(CONTENT_NEW2), changeId2);
|
new String(CONTENT_NEW2), changeId2);
|
||||||
push.to(git, "refs/for/master").assertOkStatus();
|
push.to("refs/for/master").assertOkStatus();
|
||||||
RestResponse r = adminSession.post(urlRebase());
|
RestResponse r = adminSession.post(urlRebase());
|
||||||
assertThat(r.getStatusCode()).isEqualTo(SC_CONFLICT);
|
assertThat(r.getStatusCode()).isEqualTo(SC_CONFLICT);
|
||||||
}
|
}
|
||||||
@@ -655,23 +655,23 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private String newChange(Git git, PersonIdent ident) throws Exception {
|
private String newChange(Git git, PersonIdent ident) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME,
|
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME,
|
||||||
new String(CONTENT_OLD));
|
new String(CONTENT_OLD));
|
||||||
return push.to(git, "refs/for/master").getChangeId();
|
return push.to("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String amendChange(Git git, PersonIdent ident, String changeId) throws Exception {
|
private String amendChange(Git git, PersonIdent ident, String changeId) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME2,
|
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME2,
|
||||||
new String(CONTENT_NEW2), changeId);
|
new String(CONTENT_NEW2), changeId);
|
||||||
return push.to(git, "refs/for/master").getChangeId();
|
return push.to("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String newChange2(Git git, PersonIdent ident) throws Exception {
|
private String newChange2(Git git, PersonIdent ident) throws Exception {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, ident, PushOneCommit.SUBJECT, FILE_NAME,
|
pushFactory.create(db, ident, git, PushOneCommit.SUBJECT, FILE_NAME,
|
||||||
new String(CONTENT_OLD));
|
new String(CONTENT_OLD));
|
||||||
return push.rm(git, "refs/for/master").getChangeId();
|
return push.rm("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Change getChange(String changeId) throws Exception {
|
private Change getChange(String changeId) throws Exception {
|
||||||
|
|||||||
@@ -190,9 +190,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
|||||||
assertThat(cr.all.get(0).value).is(1);
|
assertThat(cr.all.get(0).value).is(1);
|
||||||
|
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
"b.txt", "anotherContent", r.getChangeId());
|
"b.txt", "anotherContent", r.getChangeId());
|
||||||
r = push.to(git, "refs/for/master/%l=Code-Review+2");
|
r = push.to("refs/for/master/%l=Code-Review+2");
|
||||||
|
|
||||||
ci = get(r.getChangeId());
|
ci = get(r.getChangeId());
|
||||||
cr = ci.labels.get("Code-Review");
|
cr = ci.labels.get("Code-Review");
|
||||||
@@ -207,9 +207,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
|||||||
PushOneCommit.Result r = pushTo("refs/for/master");
|
PushOneCommit.Result r = pushTo("refs/for/master");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
"b.txt", "anotherContent", r.getChangeId());
|
"b.txt", "anotherContent", r.getChangeId());
|
||||||
r = push.to(git, "refs/changes/" + r.getChange().change().getId().get());
|
r = push.to("refs/changes/" + r.getChange().change().getId().get());
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,9 +255,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
|||||||
// specify a single hashtag as option in new patch set
|
// specify a single hashtag as option in new patch set
|
||||||
String hashtag2 = "tag2";
|
String hashtag2 = "tag2";
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
"b.txt", "anotherContent", r.getChangeId());
|
"b.txt", "anotherContent", r.getChangeId());
|
||||||
r = push.to(git, "refs/for/master/%hashtag=" + hashtag2);
|
r = push.to("refs/for/master/%hashtag=" + hashtag2);
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
expected = ImmutableSet.of(hashtag1, hashtag2);
|
expected = ImmutableSet.of(hashtag1, hashtag2);
|
||||||
hashtags = gApi.changes().id(r.getChangeId()).getHashtags();
|
hashtags = gApi.changes().id(r.getChangeId()).getHashtags();
|
||||||
@@ -287,10 +287,9 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
|||||||
String hashtag3 = "tag3";
|
String hashtag3 = "tag3";
|
||||||
String hashtag4 = "tag4";
|
String hashtag4 = "tag4";
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
"b.txt", "anotherContent", r.getChangeId());
|
"b.txt", "anotherContent", r.getChangeId());
|
||||||
r = push.to(git,
|
r = push.to("refs/for/master%hashtag=" + hashtag3 + ",hashtag=" + hashtag4);
|
||||||
"refs/for/master%hashtag=" + hashtag3 + ",hashtag=" + hashtag4);
|
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
expected = ImmutableSet.of(hashtag1, hashtag2, hashtag3, hashtag4);
|
expected = ImmutableSet.of(hashtag1, hashtag2, hashtag3, hashtag4);
|
||||||
hashtags = gApi.changes().id(r.getChangeId()).getHashtags();
|
hashtags = gApi.changes().id(r.getChangeId()).getHashtags();
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
public void forcePushNotAllowed() throws Exception {
|
public void forcePushNotAllowed() throws Exception {
|
||||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), "change1", "a.txt", "content");
|
pushFactory.create(db, admin.getIdent(), git, "change1", "a.txt", "content");
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/heads/master");
|
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
||||||
r1.assertOkStatus();
|
r1.assertOkStatus();
|
||||||
|
|
||||||
// Reset HEAD to initial so the new change is a non-fast forward
|
// Reset HEAD to initial so the new change is a non-fast forward
|
||||||
@@ -41,9 +41,9 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||||
|
|
||||||
PushOneCommit push2 =
|
PushOneCommit push2 =
|
||||||
pushFactory.create(db, admin.getIdent(), "change2", "b.txt", "content");
|
pushFactory.create(db, admin.getIdent(), git, "change2", "b.txt", "content");
|
||||||
push2.setForce(true);
|
push2.setForce(true);
|
||||||
PushOneCommit.Result r2 = push2.to(git, "refs/heads/master");
|
PushOneCommit.Result r2 = push2.to("refs/heads/master");
|
||||||
r2.assertErrorStatus("non-fast forward");
|
r2.assertErrorStatus("non-fast forward");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
ObjectId initial = git.getRepository().getRef(HEAD).getLeaf().getObjectId();
|
||||||
grant(Permission.PUSH, project, "refs/*", true);
|
grant(Permission.PUSH, project, "refs/*", true);
|
||||||
PushOneCommit push1 =
|
PushOneCommit push1 =
|
||||||
pushFactory.create(db, admin.getIdent(), "change1", "a.txt", "content");
|
pushFactory.create(db, admin.getIdent(), git, "change1", "a.txt", "content");
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/heads/master");
|
PushOneCommit.Result r1 = push1.to("refs/heads/master");
|
||||||
r1.assertOkStatus();
|
r1.assertOkStatus();
|
||||||
|
|
||||||
// Reset HEAD to initial so the new change is a non-fast forward
|
// Reset HEAD to initial so the new change is a non-fast forward
|
||||||
@@ -62,9 +62,9 @@ public class ForcePushIT extends AbstractDaemonTest {
|
|||||||
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
assertThat(ru.forceUpdate()).isEqualTo(RefUpdate.Result.FORCED);
|
||||||
|
|
||||||
PushOneCommit push2 =
|
PushOneCommit push2 =
|
||||||
pushFactory.create(db, admin.getIdent(), "change2", "b.txt", "content");
|
pushFactory.create(db, admin.getIdent(), git, "change2", "b.txt", "content");
|
||||||
push2.setForce(true);
|
push2.setForce(true);
|
||||||
PushOneCommit.Result r2 = push2.to(git, "refs/heads/master");
|
PushOneCommit.Result r2 = push2.to("refs/heads/master");
|
||||||
r2.assertOkStatus();
|
r2.assertOkStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
grant(Permission.CREATE, project, "refs/tags/*");
|
grant(Permission.CREATE, project, "refs/tags/*");
|
||||||
grant(Permission.PUSH, project, "refs/tags/*");
|
grant(Permission.PUSH, project, "refs/tags/*");
|
||||||
PushOneCommit.Tag tag = new PushOneCommit.Tag("v1.0");
|
PushOneCommit.Tag tag = new PushOneCommit.Tag("v1.0");
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push.setTag(tag);
|
push.setTag(tag);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r = push.to("refs/for/master%submit");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
r.assertChange(Change.Status.MERGED, null, admin);
|
r.assertChange(Change.Status.MERGED, null, admin);
|
||||||
assertSubmitApproval(r.getPatchSetId());
|
assertSubmitApproval(r.getPatchSetId());
|
||||||
@@ -90,9 +90,9 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
grant(Permission.PUSH, project, "refs/tags/*");
|
grant(Permission.PUSH, project, "refs/tags/*");
|
||||||
PushOneCommit.AnnotatedTag tag =
|
PushOneCommit.AnnotatedTag tag =
|
||||||
new PushOneCommit.AnnotatedTag("v1.0", "annotation", admin.getIdent());
|
new PushOneCommit.AnnotatedTag("v1.0", "annotation", admin.getIdent());
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push.setTag(tag);
|
push.setTag(tag);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r = push.to("refs/for/master%submit");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
r.assertChange(Change.Status.MERGED, null, admin);
|
r.assertChange(Change.Status.MERGED, null, admin);
|
||||||
assertSubmitApproval(r.getPatchSetId());
|
assertSubmitApproval(r.getPatchSetId());
|
||||||
@@ -273,15 +273,15 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
private PushOneCommit.Result push(String ref, String subject,
|
private PushOneCommit.Result push(String ref, String subject,
|
||||||
String fileName, String content) throws GitAPIException, IOException {
|
String fileName, String content) throws GitAPIException, IOException {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), subject, fileName, content);
|
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
|
||||||
return push.to(git, ref);
|
return push.to(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PushOneCommit.Result push(String ref, String subject,
|
private PushOneCommit.Result push(String ref, String subject,
|
||||||
String fileName, String content, String changeId) throws GitAPIException,
|
String fileName, String content, String changeId) throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(), subject,
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git, subject,
|
||||||
fileName, content, changeId);
|
fileName, content, changeId);
|
||||||
return push.to(git, ref);
|
return push.to(ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,11 +91,11 @@ public class VisibleRefFilterIT extends AbstractDaemonTest {
|
|||||||
.create(new BranchInput());
|
.create(new BranchInput());
|
||||||
|
|
||||||
allow(Permission.SUBMIT, admins, "refs/for/refs/heads/*");
|
allow(Permission.SUBMIT, admins, "refs/for/refs/heads/*");
|
||||||
PushOneCommit.Result mr = pushFactory.create(db, admin.getIdent())
|
PushOneCommit.Result mr = pushFactory.create(db, admin.getIdent(), git)
|
||||||
.to(git, "refs/for/master%submit");
|
.to("refs/for/master%submit");
|
||||||
mr.assertOkStatus();
|
mr.assertOkStatus();
|
||||||
PushOneCommit.Result br = pushFactory.create(db, admin.getIdent())
|
PushOneCommit.Result br = pushFactory.create(db, admin.getIdent(), git)
|
||||||
.to(git, "refs/for/branch%submit");
|
.to("refs/for/branch%submit");
|
||||||
br.assertOkStatus();
|
br.assertOkStatus();
|
||||||
|
|
||||||
Repository repo = repoManager.openRepository(project);
|
Repository repo = repoManager.openRepository(project);
|
||||||
|
|||||||
@@ -175,23 +175,23 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
|||||||
|
|
||||||
protected PushOneCommit.Result createChange(Git git) throws GitAPIException,
|
protected PushOneCommit.Result createChange(Git git) throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
return push.to(git, "refs/for/master");
|
return push.to("refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PushOneCommit.Result createChange(Git git, String subject,
|
protected PushOneCommit.Result createChange(Git git, String subject,
|
||||||
String fileName, String content) throws GitAPIException, IOException {
|
String fileName, String content) throws GitAPIException, IOException {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), subject, fileName, content);
|
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
|
||||||
return push.to(git, "refs/for/master");
|
return push.to("refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PushOneCommit.Result createChange(Git git, String subject,
|
protected PushOneCommit.Result createChange(Git git, String subject,
|
||||||
String fileName, String content, String topic)
|
String fileName, String content, String topic)
|
||||||
throws GitAPIException, IOException {
|
throws GitAPIException, IOException {
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), subject, fileName, content);
|
pushFactory.create(db, admin.getIdent(), git, subject, fileName, content);
|
||||||
return push.to(git, "refs/for/master/" + topic);
|
return push.to("refs/for/master/" + topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void submit(String changeId) throws IOException {
|
protected void submit(String changeId) throws IOException {
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ public class ActionsIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private PushOneCommit.Result createChangeWithTopic(String topic) throws GitAPIException,
|
private PushOneCommit.Result createChangeWithTopic(String topic) throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
assertThat(topic).isNotEmpty();
|
assertThat(topic).isNotEmpty();
|
||||||
return push.to(git, "refs/for/master/" + topic);
|
return push.to("refs/for/master/" + topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void approve(RestSession adminSession, String changeId)
|
static void approve(RestSession adminSession, String changeId)
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private String createMyChange() throws GitAPIException,
|
private String createMyChange() throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, user.getIdent());
|
PushOneCommit push = pushFactory.create(db, user.getIdent(), git);
|
||||||
return push.to(git, "refs/for/master").getChangeId();
|
return push.to("refs/for/master").getChangeId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ public class ConflictsOperatorIT extends AbstractDaemonTest {
|
|||||||
checkout(git, "origin/master");
|
checkout(git, "origin/master");
|
||||||
String file = conflicting ? "test.txt" : "test-" + count + ".txt";
|
String file = conflicting ? "test.txt" : "test-" + count + ".txt";
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), "Change " + count, file,
|
pushFactory.create(db, admin.getIdent(), git, "Change " + count, file,
|
||||||
"content " + count);
|
"content " + count);
|
||||||
count++;
|
count++;
|
||||||
return push.to(git, "refs/for/master");
|
return push.to("refs/for/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> queryConflictingChanges(PushOneCommit.Result change)
|
private Set<String> queryConflictingChanges(PushOneCommit.Result change)
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ public class DeleteDraftPatchSetIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
private String createDraftChangeWith2PS() throws GitAPIException,
|
private String createDraftChangeWith2PS() throws GitAPIException,
|
||||||
IOException {
|
IOException {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
Result result = push.to(git, "refs/drafts/master");
|
Result result = push.to("refs/drafts/master");
|
||||||
push = pushFactory.create(db, admin.getIdent(), PushOneCommit.SUBJECT,
|
push = pushFactory.create(db, admin.getIdent(), git, PushOneCommit.SUBJECT,
|
||||||
"b.txt", "4711", result.getChangeId());
|
"b.txt", "4711", result.getChangeId());
|
||||||
return push.to(git, "refs/drafts/master").getChangeId();
|
return push.to("refs/drafts/master").getChangeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet getCurrentPatchSet(String changeId) throws OrmException {
|
private PatchSet getCurrentPatchSet(String changeId) throws OrmException {
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ public class ListChangesOptionsIT extends AbstractDaemonTest {
|
|||||||
String subject = "Change subject";
|
String subject = "Change subject";
|
||||||
String fileName = "a.txt";
|
String fileName = "a.txt";
|
||||||
PushOneCommit push = pushFactory.create(
|
PushOneCommit push = pushFactory.create(
|
||||||
db, admin.getIdent(), subject, fileName, content, baseChangeId);
|
db, admin.getIdent(), git, subject, fileName, content, baseChangeId);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ public class GetCommitIT extends AbstractDaemonTest {
|
|||||||
@Test
|
@Test
|
||||||
public void getOpenChange_Found() throws Exception {
|
public void getOpenChange_Found() throws Exception {
|
||||||
allow(Permission.READ, REGISTERED_USERS, "refs/heads/*");
|
allow(Permission.READ, REGISTERED_USERS, "refs/heads/*");
|
||||||
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent())
|
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), git)
|
||||||
.to(git, "refs/for/master");
|
.to("refs/for/master");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
|
|
||||||
CommitInfo info = getCommit(r.getCommitId());
|
CommitInfo info = getCommit(r.getCommitId());
|
||||||
@@ -123,8 +123,8 @@ public class GetCommitIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getOpenChange_NotFound() throws Exception {
|
public void getOpenChange_NotFound() throws Exception {
|
||||||
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent())
|
PushOneCommit.Result r = pushFactory.create(db, admin.getIdent(), git)
|
||||||
.to(git, "refs/for/master");
|
.to("refs/for/master");
|
||||||
r.assertOkStatus();
|
r.assertOkStatus();
|
||||||
assertNotFound(r.getCommitId());
|
assertNotFound(r.getCommitId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
|||||||
cfg.setString("s1", null, "k1", "v1");
|
cfg.setString("s1", null, "k1", "v1");
|
||||||
cfg.setString("s2", "ss", "k2", "v2");
|
cfg.setString("s2", "ss", "k2", "v2");
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
|
pushFactory.create(db, admin.getIdent(), git, "Create Project Level Config",
|
||||||
configName, cfg.toText());
|
configName, cfg.toText());
|
||||||
push.to(git, RefNames.REFS_CONFIG);
|
push.to(RefNames.REFS_CONFIG);
|
||||||
|
|
||||||
ProjectState state = projectCache.get(project);
|
ProjectState state = projectCache.get(project);
|
||||||
assertThat(state.getConfig(configName).get().toText()).isEqualTo(
|
assertThat(state.getConfig(configName).get().toText()).isEqualTo(
|
||||||
@@ -73,16 +73,16 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
|||||||
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
|
fetch(parentGit, RefNames.REFS_CONFIG + ":refs/heads/config");
|
||||||
checkout(parentGit, "refs/heads/config");
|
checkout(parentGit, "refs/heads/config");
|
||||||
PushOneCommit push =
|
PushOneCommit push =
|
||||||
pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
|
pushFactory.create(db, admin.getIdent(), parentGit, "Create Project Level Config",
|
||||||
configName, parentCfg.toText());
|
configName, parentCfg.toText());
|
||||||
push.to(parentGit, RefNames.REFS_CONFIG);
|
push.to(RefNames.REFS_CONFIG);
|
||||||
|
|
||||||
Config cfg = new Config();
|
Config cfg = new Config();
|
||||||
cfg.setString("s1", null, "k1", "childValue1");
|
cfg.setString("s1", null, "k1", "childValue1");
|
||||||
cfg.setString("s2", "ss", "k3", "childValue2");
|
cfg.setString("s2", "ss", "k3", "childValue2");
|
||||||
push = pushFactory.create(db, admin.getIdent(), "Create Project Level Config",
|
push = pushFactory.create(db, admin.getIdent(), git, "Create Project Level Config",
|
||||||
configName, cfg.toText());
|
configName, cfg.toText());
|
||||||
push.to(git, RefNames.REFS_CONFIG);
|
push.to(RefNames.REFS_CONFIG);
|
||||||
|
|
||||||
ProjectState state = projectCache.get(project);
|
ProjectState state = projectCache.get(project);
|
||||||
|
|
||||||
|
|||||||
@@ -50,16 +50,16 @@ public class TagsIT extends AbstractDaemonTest {
|
|||||||
grant(Permission.PUSH, project, "refs/tags/*");
|
grant(Permission.PUSH, project, "refs/tags/*");
|
||||||
|
|
||||||
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
||||||
PushOneCommit push1 = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push1.setTag(tag1);
|
push1.setTag(tag1);
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
|
||||||
r1.assertOkStatus();
|
r1.assertOkStatus();
|
||||||
|
|
||||||
PushOneCommit.AnnotatedTag tag2 =
|
PushOneCommit.AnnotatedTag tag2 =
|
||||||
new PushOneCommit.AnnotatedTag("v2.0", "annotation", admin.getIdent());
|
new PushOneCommit.AnnotatedTag("v2.0", "annotation", admin.getIdent());
|
||||||
PushOneCommit push2 = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push2.setTag(tag2);
|
push2.setTag(tag2);
|
||||||
PushOneCommit.Result r2 = push2.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r2 = push2.to("refs/for/master%submit");
|
||||||
r2.assertOkStatus();
|
r2.assertOkStatus();
|
||||||
|
|
||||||
List<TagInfo> result =
|
List<TagInfo> result =
|
||||||
@@ -86,16 +86,16 @@ public class TagsIT extends AbstractDaemonTest {
|
|||||||
grant(Permission.PUSH, project, "refs/tags/*");
|
grant(Permission.PUSH, project, "refs/tags/*");
|
||||||
|
|
||||||
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
||||||
PushOneCommit push1 = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push1.setTag(tag1);
|
push1.setTag(tag1);
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
|
||||||
r1.assertOkStatus();
|
r1.assertOkStatus();
|
||||||
|
|
||||||
pushTo("refs/heads/hidden");
|
pushTo("refs/heads/hidden");
|
||||||
PushOneCommit.Tag tag2 = new PushOneCommit.Tag("v2.0");
|
PushOneCommit.Tag tag2 = new PushOneCommit.Tag("v2.0");
|
||||||
PushOneCommit push2 = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push2.setTag(tag2);
|
push2.setTag(tag2);
|
||||||
PushOneCommit.Result r2 = push2.to(git, "refs/for/hidden%submit");
|
PushOneCommit.Result r2 = push2.to("refs/for/hidden%submit");
|
||||||
r2.assertOkStatus();
|
r2.assertOkStatus();
|
||||||
|
|
||||||
List<TagInfo> result =
|
List<TagInfo> result =
|
||||||
@@ -121,9 +121,9 @@ public class TagsIT extends AbstractDaemonTest {
|
|||||||
grant(Permission.PUSH, project, "refs/tags/*");
|
grant(Permission.PUSH, project, "refs/tags/*");
|
||||||
|
|
||||||
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
PushOneCommit.Tag tag1 = new PushOneCommit.Tag("v1.0");
|
||||||
PushOneCommit push1 = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), git);
|
||||||
push1.setTag(tag1);
|
push1.setTag(tag1);
|
||||||
PushOneCommit.Result r1 = push1.to(git, "refs/for/master%submit");
|
PushOneCommit.Result r1 = push1.to("refs/for/master%submit");
|
||||||
r1.assertOkStatus();
|
r1.assertOkStatus();
|
||||||
|
|
||||||
RestResponse response =
|
RestResponse response =
|
||||||
|
|||||||
@@ -87,9 +87,9 @@ public class CommentsIT extends AbstractDaemonTest {
|
|||||||
for (Integer line : lines) {
|
for (Integer line : lines) {
|
||||||
String file = "file";
|
String file = "file";
|
||||||
String contents = "contents " + line;
|
String contents = "contents " + line;
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"first subject", file, contents);
|
"first subject", file, contents);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
String changeId = r.getChangeId();
|
String changeId = r.getChangeId();
|
||||||
String revId = r.getCommit().getName();
|
String revId = r.getCommit().getName();
|
||||||
ReviewInput input = new ReviewInput();
|
ReviewInput input = new ReviewInput();
|
||||||
@@ -161,9 +161,9 @@ public class CommentsIT extends AbstractDaemonTest {
|
|||||||
for (Integer line : lines) {
|
for (Integer line : lines) {
|
||||||
String file = "file";
|
String file = "file";
|
||||||
String contents = "contents " + line;
|
String contents = "contents " + line;
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"first subject", file, contents);
|
"first subject", file, contents);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
String changeId = r.getChangeId();
|
String changeId = r.getChangeId();
|
||||||
String revId = r.getCommit().getName();
|
String revId = r.getCommit().getName();
|
||||||
ReviewInput input = new ReviewInput();
|
ReviewInput input = new ReviewInput();
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRelatedNoResult() throws Exception {
|
public void getRelatedNoResult() throws Exception {
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PatchSet.Id ps = push.to(git, "refs/for/master").getPatchSetId();
|
PatchSet.Id ps = push.to("refs/for/master").getPatchSetId();
|
||||||
List<ChangeAndCommit> related = getRelated(ps);
|
List<ChangeAndCommit> related = getRelated(ps);
|
||||||
assertThat(related).isEmpty();
|
assertThat(related).isEmpty();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,15 +127,15 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
String file = "a.txt";
|
String file = "a.txt";
|
||||||
String contents = "contents";
|
String contents = "contents";
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"first subject", file, contents);
|
"first subject", file, contents);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
revision(r).review(ReviewInput.recommend());
|
revision(r).review(ReviewInput.recommend());
|
||||||
assertApproval(r, 1);
|
assertApproval(r, 1);
|
||||||
|
|
||||||
push = pushFactory.create(db, admin.getIdent(),
|
push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"second subject", file, contents, r.getChangeId());
|
"second subject", file, contents, r.getChangeId());
|
||||||
r = push.to(git, "refs/for/master");
|
r = push.to("refs/for/master");
|
||||||
assertApproval(r, 0);
|
assertApproval(r, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,15 +146,15 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
codeReview.setCopyAllScoresIfNoCodeChange(true);
|
codeReview.setCopyAllScoresIfNoCodeChange(true);
|
||||||
saveLabelConfig();
|
saveLabelConfig();
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"first subject", file, contents);
|
"first subject", file, contents);
|
||||||
PushOneCommit.Result r = push.to(git, "refs/for/master");
|
PushOneCommit.Result r = push.to("refs/for/master");
|
||||||
revision(r).review(ReviewInput.recommend());
|
revision(r).review(ReviewInput.recommend());
|
||||||
assertApproval(r, 1);
|
assertApproval(r, 1);
|
||||||
|
|
||||||
push = pushFactory.create(db, admin.getIdent(),
|
push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"second subject", file, contents, r.getChangeId());
|
"second subject", file, contents, r.getChangeId());
|
||||||
r = push.to(git, "refs/for/master");
|
r = push.to("refs/for/master");
|
||||||
assertApproval(r, 1);
|
assertApproval(r, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,18 +164,18 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
String file = "a.txt";
|
String file = "a.txt";
|
||||||
String contents = "contents";
|
String contents = "contents";
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r1 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r1 = push.to("refs/for/master");
|
||||||
merge(r1);
|
merge(r1);
|
||||||
|
|
||||||
push = pushFactory.create(db, admin.getIdent(),
|
push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"non-conflicting", "b.txt", "other contents");
|
"non-conflicting", "b.txt", "other contents");
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
merge(r2);
|
merge(r2);
|
||||||
|
|
||||||
git.checkout().setName(r1.getCommit().name()).call();
|
git.checkout().setName(r1.getCommit().name()).call();
|
||||||
push = pushFactory.create(db, admin.getIdent(), subject, file, contents);
|
push = pushFactory.create(db, admin.getIdent(), git, subject, file, contents);
|
||||||
PushOneCommit.Result r3 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r3 = push.to("refs/for/master");
|
||||||
revision(r3).review(ReviewInput.recommend());
|
revision(r3).review(ReviewInput.recommend());
|
||||||
assertApproval(r3, 1);
|
assertApproval(r3, 1);
|
||||||
|
|
||||||
@@ -191,18 +191,18 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
codeReview.setCopyAllScoresOnTrivialRebase(true);
|
codeReview.setCopyAllScoresOnTrivialRebase(true);
|
||||||
saveLabelConfig();
|
saveLabelConfig();
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent());
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git);
|
||||||
PushOneCommit.Result r1 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r1 = push.to("refs/for/master");
|
||||||
merge(r1);
|
merge(r1);
|
||||||
|
|
||||||
push = pushFactory.create(db, admin.getIdent(),
|
push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
"non-conflicting", "b.txt", "other contents");
|
"non-conflicting", "b.txt", "other contents");
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
merge(r2);
|
merge(r2);
|
||||||
|
|
||||||
git.checkout().setName(r1.getCommit().name()).call();
|
git.checkout().setName(r1.getCommit().name()).call();
|
||||||
push = pushFactory.create(db, admin.getIdent(), subject, file, contents);
|
push = pushFactory.create(db, admin.getIdent(), git, subject, file, contents);
|
||||||
PushOneCommit.Result r3 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r3 = push.to("refs/for/master");
|
||||||
revision(r3).review(ReviewInput.recommend());
|
revision(r3).review(ReviewInput.recommend());
|
||||||
assertApproval(r3, 1);
|
assertApproval(r3, 1);
|
||||||
|
|
||||||
@@ -218,9 +218,9 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
PushOneCommit.Result r1 = createChange();
|
PushOneCommit.Result r1 = createChange();
|
||||||
git.checkout().setName(r1.getCommit().name()).call();
|
git.checkout().setName(r1.getCommit().name()).call();
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
PushOneCommit.SUBJECT, "b.txt", "other contents");
|
PushOneCommit.SUBJECT, "b.txt", "other contents");
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
|
|
||||||
revision(r2).review(ReviewInput.recommend());
|
revision(r2).review(ReviewInput.recommend());
|
||||||
|
|
||||||
@@ -248,9 +248,9 @@ public class LabelTypeIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
git.checkout().setName(r1.getCommit().name()).call();
|
git.checkout().setName(r1.getCommit().name()).call();
|
||||||
|
|
||||||
PushOneCommit push = pushFactory.create(db, admin.getIdent(),
|
PushOneCommit push = pushFactory.create(db, admin.getIdent(), git,
|
||||||
PushOneCommit.SUBJECT, "b.txt", "other contents");
|
PushOneCommit.SUBJECT, "b.txt", "other contents");
|
||||||
PushOneCommit.Result r2 = push.to(git, "refs/for/master");
|
PushOneCommit.Result r2 = push.to("refs/for/master");
|
||||||
|
|
||||||
revision(r2).review(ReviewInput.recommend());
|
revision(r2).review(ReviewInput.recommend());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user