use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class AbstractSubmoduleSubscription method pushChangeTo.
protected ObjectId pushChangeTo(TestRepository<?> repo, String ref, String file, String content, String message, String topic) throws Exception {
ObjectId ret = repo.branch("HEAD").commit().insertChangeId().message(message).add(file, content).create();
String pushedRef = ref;
if (!topic.isEmpty()) {
pushedRef += "/" + name(topic);
}
String refspec = "HEAD:" + pushedRef;
Iterable<PushResult> res = repo.git().push().setRemote("origin").setRefSpecs(new RefSpec(refspec)).call();
RemoteRefUpdate u = Iterables.getOnlyElement(res).getRemoteUpdate(pushedRef);
assertThat(u).isNotNull();
assertThat(u.getStatus()).isEqualTo(Status.OK);
assertThat(u.getNewObjectId()).isEqualTo(ret);
return ret;
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class CreateChangeIT method alreadyMerged.
@Test
public void alreadyMerged() throws Exception {
ObjectId c0 = testRepo.branch("HEAD").commit().insertChangeId().message("first commit").add("a.txt", "a contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
testRepo.branch("HEAD").commit().insertChangeId().message("second commit").add("b.txt", "b contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
ChangeInput in = newMergeChangeInput("master", c0.getName(), "");
assertCreateFails(in, ChangeAlreadyMergedException.class, "'" + c0.getName() + "' has already been merged");
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class CreateChangeIT method onlyContentMerged.
@Test
public void onlyContentMerged() throws Exception {
testRepo.branch("HEAD").commit().insertChangeId().message("first commit").add("a.txt", "a contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
// create a change, and cherrypick into master
PushOneCommit.Result cId = createChange();
RevCommit commitId = cId.getCommit();
CherryPickInput cpi = new CherryPickInput();
cpi.destination = "master";
cpi.message = "cherry pick the commit";
ChangeApi orig = gApi.changes().id(cId.getChangeId());
ChangeApi cherry = orig.current().cherryPick(cpi);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
ObjectId remoteId = getRemoteHead();
assertThat(remoteId).isNotEqualTo(commitId);
ChangeInput in = newMergeChangeInput("master", commitId.getName(), "");
assertCreateSucceeds(in);
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class SubmitByMergeIfNecessaryIT method openChangeForTargetBranchPreventsMerge.
@Test
public void openChangeForTargetBranchPreventsMerge() throws Exception {
gApi.projects().name(project.get()).branch("stable").create(new BranchInput());
// Propose a change for master, but leave it open for master!
PushOneCommit change = pushFactory.create(db, user.getIdent(), testRepo, "small fix", "a.txt", "2");
PushOneCommit.Result change2result = change.to("refs/for/master");
// Now cherry pick to stable
CherryPickInput in = new CherryPickInput();
in.destination = "stable";
in.message = "it goes to stable branch";
ChangeApi orig = gApi.changes().id(change2result.getChangeId());
ChangeApi cherry = orig.current().cherryPick(in);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
// Create a commit locally
testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();
PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
submitWithConflict(change3.getChangeId(), "Failed to submit 1 change due to the following problems:\n" + "Change " + change3.getPatchSetId().getParentKey().get() + ": depends on change that was not submitted");
assertRefUpdatedEvents();
assertChangeMergedEvents();
}
use of org.eclipse.jgit.transport.RefSpec in project gerrit by GerritCodeReview.
the class CheckMergeabilityIT method checkOursMergeStrategy.
@Test
public void checkOursMergeStrategy() throws Exception {
RevCommit initialHead = getRemoteHead();
testRepo.branch("HEAD").commit().insertChangeId().message("some change in a").add("a.txt", "a contents ").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
testRepo.reset(initialHead);
testRepo.branch("HEAD").commit().insertChangeId().message("some change in a too").add("a.txt", "a contents too").create();
testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/test")).call();
assertMergeable("master", "test", "ours");
}
Aggregations