use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revertSubmissionRevertsChangeWithLongSubject.
@Test
public void revertSubmissionRevertsChangeWithLongSubject() throws Exception {
String changeTitle = "This change has a very long title and therefore it will be cut to 56 characters when the" + " revert change will revert this change";
String result = createChange(changeTitle, "a.txt", "message").getChangeId();
gApi.changes().id(result).current().review(ReviewInput.approve());
gApi.changes().id(result).current().submit();
RevertInput revertInput = new RevertInput();
ChangeInfo revertChange = gApi.changes().id(result).revertSubmission(revertInput).revertChanges.get(0);
assertThat(revertChange.subject).isEqualTo(String.format("Revert \"%s...\"", changeTitle.substring(0, 56)));
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Revert \"%s...\"\n\nThis reverts commit %s.\n\nChange-Id: %s\n", changeTitle.substring(0, 56), gApi.changes().id(result).get().currentRevision, revertChange.changeId));
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevertIT method revertWithSetMessageChangeIdIgnored.
@Test
public void revertWithSetMessageChangeIdIgnored() throws Exception {
PushOneCommit.Result result = createChange();
gApi.changes().id(result.getChangeId()).current().review(ReviewInput.approve());
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
RevertInput revertInput = new RevertInput();
String fakeChangeId = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
String commitSubject = "Message from input";
revertInput.message = String.format("%s\n\nChange-Id: %s\n", commitSubject, fakeChangeId);
ChangeInfo revertChange = gApi.changes().id(result.getChangeId()).revert(revertInput).get();
// ChangeId provided in revert input is ignored.
assertThat(revertChange.changeId).isNotEqualTo(fakeChangeId);
assertThat(revertChange.subject).isEqualTo(commitSubject);
// ChangeId footer was replaced in revert commit message.
assertThat(gApi.changes().id(revertChange.id).current().commit(false).message).isEqualTo(String.format("Message from input\n\nChange-Id: %s\n", revertChange.changeId));
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class AgreementsIT method revertChangeWithoutCLA.
@Test
public void revertChangeWithoutCLA() throws Exception {
assume().that(isContributorAgreementsEnabled()).isTrue();
// Create a change succeeds when agreement is not required
setUseContributorAgreements(InheritableBoolean.FALSE);
ChangeInfo change = gApi.changes().create(newChangeInput()).get();
// Approve and submit it
requestScopeOperations.setApiUser(admin.id());
gApi.changes().id(change.changeId).current().review(ReviewInput.approve());
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
// Revert is not allowed when CLA is required but not signed
requestScopeOperations.setApiUser(user.id());
setUseContributorAgreements(InheritableBoolean.TRUE);
AuthException thrown = assertThrows(AuthException.class, () -> gApi.changes().id(change.changeId).revert());
assertThat(thrown).hasMessageThat().contains("Contributor Agreement");
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class AgreementsIT method cherrypickChangeWithoutCLA.
@Test
public void cherrypickChangeWithoutCLA() throws Exception {
assume().that(isContributorAgreementsEnabled()).isTrue();
// Create a new branch
requestScopeOperations.setApiUser(admin.id());
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
requestScopeOperations.setApiUser(user.id());
setUseContributorAgreements(InheritableBoolean.TRUE);
CherryPickInput in = new CherryPickInput();
in.destination = dest.ref;
in.message = change.subject;
AuthException thrown = assertThrows(AuthException.class, () -> gApi.changes().id(change.changeId).current().cherryPick(in));
assertThat(thrown).hasMessageThat().contains("Contributor Agreement");
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class AbandonIT method abandon.
@Test
public void abandon() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = r.getChangeId();
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
gApi.changes().id(changeId).abandon();
ChangeInfo info = get(changeId, MESSAGES);
assertThat(info.status).isEqualTo(ChangeStatus.ABANDONED);
assertThat(Iterables.getLast(info.messages).message.toLowerCase()).contains("abandoned");
ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.changes().id(changeId).abandon());
assertThat(thrown).hasMessageThat().contains("change is abandoned");
}
Aggregations