use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitWithCommitAndItsMergeCommitTogether.
@Test
public void submitWithCommitAndItsMergeCommitTogether() throws Exception {
assume().that(isSubmitWholeTopicEnabled()).isTrue();
RevCommit initialHead = getRemoteHead();
// Create a stable branch and bootstrap it.
gApi.projects().name(project.get()).branch("stable").create(new BranchInput());
PushOneCommit push = pushFactory.create(db, user.getIdent(), testRepo, "initial commit", "a.txt", "a");
PushOneCommit.Result change = push.to("refs/heads/stable");
RevCommit stable = getRemoteHead(project, "stable");
RevCommit master = getRemoteHead(project, "master");
assertThat(master).isEqualTo(initialHead);
assertThat(stable).isEqualTo(change.getCommit());
testRepo.git().fetch().call();
testRepo.git().branchCreate().setName("stable").setStartPoint(stable).call();
testRepo.git().branchCreate().setName("master").setStartPoint(master).call();
// Create a fix in stable branch.
testRepo.reset(stable);
RevCommit fix = testRepo.commit().parent(stable).message("small fix").add("b.txt", "b").insertChangeId().create();
testRepo.branch("refs/heads/stable").update(fix);
testRepo.git().push().setRefSpecs(new RefSpec("refs/heads/stable:refs/for/stable/" + name("topic"))).call();
// Merge the fix into master.
testRepo.reset(master);
RevCommit merge = testRepo.commit().parent(master).parent(fix).message("Merge stable into master").insertChangeId().create();
testRepo.branch("refs/heads/master").update(merge);
testRepo.git().push().setRefSpecs(new RefSpec("refs/heads/master:refs/for/master/" + name("topic"))).call();
// Submit together.
String fixId = GitUtil.getChangeId(testRepo, fix).get();
String mergeId = GitUtil.getChangeId(testRepo, merge).get();
approve(fixId);
approve(mergeId);
submit(mergeId);
assertMerged(fixId);
assertMerged(mergeId);
testRepo.git().fetch().call();
RevWalk rw = testRepo.getRevWalk();
master = rw.parseCommit(getRemoteHead(project, "master"));
assertThat(rw.isMergedInto(merge, master)).isTrue();
assertThat(rw.isMergedInto(fix, master)).isTrue();
}
use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.
the class AgreementsIT method cherrypickChangeWithoutCLA.
@Test
public void cherrypickChangeWithoutCLA() throws Exception {
assume().that(isContributorAgreementsEnabled()).isTrue();
// Create a new branch
setApiUser(admin);
BranchInfo dest = gApi.projects().name(project.get()).branch("cherry-pick-to").create(new BranchInput()).get();
// Create a change succeeds when agreement is not required
setUseContributorAgreements(InheritableBoolean.FALSE);
ChangeInfo change = gApi.changes().create(newChangeInput()).get();
// Approve and submit it
gApi.changes().id(change.changeId).current().review(ReviewInput.approve());
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
// Cherry-pick is not allowed when CLA is required but not signed
setApiUser(user);
setUseContributorAgreements(InheritableBoolean.TRUE);
CherryPickInput in = new CherryPickInput();
in.destination = dest.ref;
in.message = change.subject;
exception.expect(AuthException.class);
exception.expectMessage("A Contributor Agreement must be completed");
gApi.changes().id(change.changeId).current().cherryPick(in);
}
use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.
the class ChangeIT method getAmbiguous.
@Test
public void getAmbiguous() throws Exception {
PushOneCommit.Result r1 = createChange();
String changeId = r1.getChangeId();
gApi.changes().id(changeId).get();
BranchInput b = new BranchInput();
b.revision = repo().exactRef("HEAD").getObjectId().name();
gApi.projects().name(project.get()).branch("other").create(b);
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, PushOneCommit.FILE_NAME, PushOneCommit.FILE_CONTENT, changeId);
PushOneCommit.Result r2 = push2.to("refs/for/other");
assertThat(r2.getChangeId()).isEqualTo(changeId);
exception.expect(ResourceNotFoundException.class);
exception.expectMessage("Multiple changes found for " + changeId);
gApi.changes().id(changeId).get();
}
use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.
the class SubmitTypeRuleIT method setUp.
@Before
public void setUp() throws Exception {
fileCounter = new AtomicInteger();
gApi.projects().name(project.get()).branch("test").create(new BranchInput());
testChangeId = createChange("test", "test change").getChange().getId();
}
use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.
the class ProjectIT method createBranch.
@Test
public void createBranch() throws Exception {
allow(Permission.READ, ANONYMOUS_USERS, "refs/*");
gApi.projects().name(project.get()).branch("foo").create(new BranchInput());
}
Aggregations