use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertIT method revertSubmissionSuppressNotifications.
@Test
public void revertSubmissionSuppressNotifications() throws Exception {
String firstResult = createChange("first change", "a.txt", "message").getChangeId();
approve(firstResult);
gApi.changes().id(firstResult).addReviewer(user.email());
String secondResult = createChange("second change", "b.txt", "other").getChangeId();
approve(secondResult);
gApi.changes().id(secondResult).addReviewer(user.email());
gApi.changes().id(secondResult).current().submit();
sender.clear();
RevertInput revertInput = new RevertInput();
revertInput.notify = NotifyHandling.NONE;
gApi.changes().id(secondResult).revertSubmission(revertInput);
assertThat(sender.getMessages()).isEmpty();
}
use of com.google.gerrit.extensions.api.changes.RevertInput in project gerrit by GerritCodeReview.
the class RevertSubmission method revertSubmission.
private RevertSubmissionInfo revertSubmission(List<ChangeData> changeData, RevertInput revertInput) throws RestApiException, IOException, UpdateException, ConfigInvalidException, StorageException, PermissionBackendException {
Multimap<BranchNameKey, ChangeData> changesPerProjectAndBranch = ArrayListMultimap.create();
changeData.stream().forEach(c -> changesPerProjectAndBranch.put(c.change().getDest(), c));
cherryPickInput = createCherryPickInput(revertInput);
Instant timestamp = TimeUtil.now();
for (BranchNameKey projectAndBranch : changesPerProjectAndBranch.keySet()) {
cherryPickInput.base = null;
Project.NameKey project = projectAndBranch.project();
cherryPickInput.destination = projectAndBranch.branch();
if (revertInput.workInProgress) {
cherryPickInput.notify = firstNonNull(cherryPickInput.notify, NotifyHandling.OWNER);
}
Collection<ChangeData> changesInProjectAndBranch = changesPerProjectAndBranch.get(projectAndBranch);
// Sort the changes topologically.
Iterator<PatchSetData> sortedChangesInProjectAndBranch = sorter.sort(changesInProjectAndBranch).iterator();
Set<ObjectId> commitIdsInProjectAndBranch = changesInProjectAndBranch.stream().map(c -> c.currentPatchSet().commitId()).collect(Collectors.toSet());
revertAllChangesInProjectAndBranch(revertInput, project, sortedChangesInProjectAndBranch, commitIdsInProjectAndBranch, timestamp);
}
results.sort(Comparator.comparing(c -> c.revertOf));
RevertSubmissionInfo revertSubmissionInfo = new RevertSubmissionInfo();
revertSubmissionInfo.revertChanges = results;
return revertSubmissionInfo;
}
Aggregations