use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class MergedByPushOp method updateChange.
@Override
public boolean updateChange(ChangeContext ctx) throws OrmException, IOException {
change = ctx.getChange();
correctBranch = refName.equals(change.getDest().get());
if (!correctBranch) {
return false;
}
if (patchSetProvider != null) {
// Caller might have also arranged for construction of a new patch set
// that is not present in the old notes so we can't use PatchSetUtil.
patchSet = patchSetProvider.get();
} else {
patchSet = checkNotNull(psUtil.get(ctx.getDb(), ctx.getNotes(), psId), "patch set %s not found", psId);
}
info = getPatchSetInfo(ctx);
ChangeUpdate update = ctx.getUpdate(psId);
Change.Status status = change.getStatus();
if (status == Change.Status.MERGED) {
return true;
}
if (status.isOpen()) {
change.setCurrentPatchSet(info);
change.setStatus(Change.Status.MERGED);
// we cannot reconstruct the submit records for when this change was
// submitted, this is why we must fix the status
update.fixStatus(Change.Status.MERGED);
update.setCurrentPatchSet();
}
StringBuilder msgBuf = new StringBuilder();
msgBuf.append("Change has been successfully pushed");
if (!refName.equals(change.getDest().get())) {
msgBuf.append(" into ");
if (refName.startsWith(Constants.R_HEADS)) {
msgBuf.append("branch ");
msgBuf.append(Repository.shortenRefName(refName));
} else {
msgBuf.append(refName);
}
}
msgBuf.append(".");
ChangeMessage msg = ChangeMessagesUtil.newMessage(psId, ctx.getUser(), ctx.getWhen(), msgBuf.toString(), ChangeMessagesUtil.TAG_MERGED);
cmUtil.addChangeMessage(ctx.getDb(), update, msg);
PatchSetApproval submitter = ApprovalsUtil.newApproval(change.currentPatchSetId(), ctx.getUser(), LabelId.legacySubmit(), 1, ctx.getWhen());
update.putApproval(submitter.getLabel(), submitter.getValue());
ctx.getDb().patchSetApprovals().upsert(Collections.singleton(submitter));
return true;
}
use of com.google.gerrit.reviewdb.client.ChangeMessage in project gerrit by GerritCodeReview.
the class ChangeData method reviewedBy.
public Set<Account.Id> reviewedBy() throws OrmException {
if (reviewedBy == null) {
if (!lazyLoad) {
return Collections.emptySet();
}
Change c = change();
if (c == null) {
return Collections.emptySet();
}
List<ReviewedByEvent> events = new ArrayList<>();
for (ChangeMessage msg : messages()) {
if (msg.getAuthor() != null) {
events.add(ReviewedByEvent.create(msg));
}
}
events = Lists.reverse(events);
reviewedBy = new LinkedHashSet<>();
Account.Id owner = c.getOwner();
for (ReviewedByEvent event : events) {
if (owner.equals(event.author())) {
break;
}
reviewedBy.add(event.author());
}
}
return reviewedBy;
}
Aggregations