use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class PushTagIT method pushTagDeletion.
private void pushTagDeletion(TagType tagType, String tagName, Status expectedStatus) throws Exception {
String tagRef = tagRef(tagName);
PushResult r = deleteRef(testRepo, tagRef);
RemoteRefUpdate refUpdate = r.getRemoteUpdate(tagRef);
assertThat(refUpdate.getStatus()).named(tagType.name()).isEqualTo(expectedStatus);
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushSameCommitTwiceUsingMagicBranchBaseOption.
@Test
public void pushSameCommitTwiceUsingMagicBranchBaseOption() throws Exception {
grant(project, "refs/heads/master", Permission.PUSH);
PushOneCommit.Result rBase = pushTo("refs/heads/master");
rBase.assertOkStatus();
gApi.projects().name(project.get()).branch("foo").create(new BranchInput());
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
PushOneCommit.Result r = push.to("refs/for/master");
r.assertOkStatus();
PushResult pr = GitUtil.pushHead(testRepo, "refs/for/foo%base=" + rBase.getCommit().name(), false, false);
// BatchUpdate implementations differ in how they hook into progress monitors. We mostly just
// care that there is a new change.
assertThat(pr.getMessages()).containsMatch("changes: new: 1,( refs: 1)? done");
assertTwoChangesWithSameRevision(r);
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushInitialCommitForMasterBranch.
@Test
@TestProjectInput(createEmptyCommit = false)
public void pushInitialCommitForMasterBranch() throws Exception {
RevCommit c = testRepo.commit().message("Initial commit").insertChangeId().create();
String id = GitUtil.getChangeId(testRepo, c).get();
testRepo.reset(c);
String r = "refs/for/master";
PushResult pr = pushHead(testRepo, r, false);
assertPushOk(pr, r);
ChangeInfo change = gApi.changes().id(id).info();
assertThat(change.branch).isEqualTo("master");
assertThat(change.status).isEqualTo(ChangeStatus.NEW);
try (Repository repo = repoManager.openRepository(project)) {
assertThat(repo.resolve("master")).isNull();
}
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class AbstractPushForReview method mergedOptionWithNewCommitWithSameChangeIdFails.
@Test
public void mergedOptionWithNewCommitWithSameChangeIdFails() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(r.getChangeId()).current().submit();
RevCommit c2 = testRepo.amend(r.getCommit()).message("New subject").insertChangeId(r.getChangeId().substring(1)).create();
testRepo.reset(c2);
String ref = "refs/for/master%merged";
PushResult pr = pushHead(testRepo, ref, false);
RemoteRefUpdate rru = pr.getRemoteUpdate(ref);
assertThat(rru.getStatus()).isEqualTo(RemoteRefUpdate.Status.REJECTED_OTHER_REASON);
assertThat(rru.getMessage()).contains("not merged into branch");
}
use of org.eclipse.jgit.transport.PushResult in project gerrit by GerritCodeReview.
the class GitUtil method pushOne.
public static PushResult pushOne(TestRepository<?> testRepo, String source, String target, boolean pushTags, boolean force, List<String> pushOptions) throws GitAPIException {
PushCommand pushCmd = testRepo.git().push();
pushCmd.setForce(force);
pushCmd.setPushOptions(pushOptions);
pushCmd.setRefSpecs(new RefSpec(source + ":" + target));
if (pushTags) {
pushCmd.setPushTags();
}
Iterable<PushResult> r = pushCmd.call();
return Iterables.getOnlyElement(r);
}
Aggregations