use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class AbandonOp method updateChange.
@Override
public boolean updateChange(ChangeContext ctx) throws ResourceConflictException {
change = ctx.getChange();
PatchSet.Id psId = change.currentPatchSetId();
ChangeUpdate update = ctx.getUpdate(psId);
if (!change.isNew()) {
throw new ResourceConflictException("change is " + ChangeUtil.status(change));
}
patchSet = psUtil.get(ctx.getNotes(), psId);
change.setStatus(Change.Status.ABANDONED);
change.setLastUpdatedOn(ctx.getWhen());
update.setStatus(change.getStatus());
mailMessage = cmUtil.setChangeMessage(ctx, commentMessage(), ChangeMessagesUtil.TAG_ABANDON);
return true;
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class EventFactory method addPatchSets.
public void addPatchSets(RevWalk revWalk, ChangeAttribute ca, Collection<PatchSet> ps, Map<PatchSet.Id, Collection<PatchSetApproval>> approvals, boolean includeFiles, Change change, LabelTypes labelTypes) {
if (!ps.isEmpty()) {
ca.patchSets = new ArrayList<>(ps.size());
for (PatchSet p : ps) {
PatchSetAttribute psa = asPatchSetAttribute(revWalk, change, p);
if (approvals != null) {
addApprovals(psa, p.id(), approvals, labelTypes);
}
ca.patchSets.add(psa);
if (includeFiles) {
addPatchSetFileNames(psa, change, p);
}
}
}
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class ChangeEditModifier method createEdit.
/**
* Creates a new change edit.
*
* @param repository the affected Git repository
* @param notes the {@link ChangeNotes} of the change for which the change edit should be created
* @throws AuthException if the user isn't authenticated or not allowed to use change edits
* @throws InvalidChangeOperationException if a change edit already existed for the change
*/
public void createEdit(Repository repository, ChangeNotes notes) throws AuthException, IOException, InvalidChangeOperationException, PermissionBackendException, ResourceConflictException {
assertCanEdit(notes);
Optional<ChangeEdit> changeEdit = lookupChangeEdit(notes);
if (changeEdit.isPresent()) {
throw new InvalidChangeOperationException(String.format("A change edit already exists for change %s", notes.getChangeId()));
}
PatchSet currentPatchSet = lookupCurrentPatchSet(notes);
ObjectId patchSetCommitId = currentPatchSet.commitId();
noteDbEdits.createEdit(repository, notes, currentPatchSet, patchSetCommitId, TimeUtil.now());
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class StreamEventsApiListener method onCommentAdded.
@Override
public void onCommentAdded(CommentAddedListener.Event ev) {
try {
ChangeNotes notes = getNotes(ev.getChange());
Change change = notes.getChange();
PatchSet ps = getPatchSet(notes, ev.getRevision());
CommentAddedEvent event = new CommentAddedEvent(change);
event.change = changeAttributeSupplier(change, notes);
event.author = accountAttributeSupplier(ev.getWho());
event.patchSet = patchSetAttributeSupplier(change, ps);
event.comment = ev.getComment();
event.approvals = approvalsAttributeSupplier(change, ev.getApprovals(), ev.getOldApprovals());
dispatcher.run(d -> d.postEvent(change, event));
} catch (StorageException e) {
logger.atSevere().withCause(e).log("Failed to dispatch event");
}
}
use of com.google.gerrit.entities.PatchSet in project gerrit by GerritCodeReview.
the class StreamEventsApiListener method onWorkInProgressStateChanged.
@Override
public void onWorkInProgressStateChanged(WorkInProgressStateChangedListener.Event ev) {
try {
ChangeNotes notes = getNotes(ev.getChange());
Change change = notes.getChange();
PatchSet patchSet = getPatchSet(notes, ev.getRevision());
WorkInProgressStateChangedEvent event = new WorkInProgressStateChangedEvent(change);
event.change = changeAttributeSupplier(change, notes);
event.changer = accountAttributeSupplier(ev.getWho());
event.patchSet = patchSetAttributeSupplier(change, patchSet);
dispatcher.run(d -> d.postEvent(change, event));
} catch (StorageException e) {
logger.atSevere().withCause(e).log("Failed to dispatch event");
}
}
Aggregations