use of com.google.gerrit.server.update.RepoView in project gerrit by GerritCodeReview.
the class PublishCommentsOp method postUpdate.
@Override
public void postUpdate(PostUpdateContext ctx) {
if (Strings.isNullOrEmpty(mailMessage) || comments.isEmpty()) {
return;
}
ChangeNotes changeNotes = changeNotesFactory.createChecked(projectNameKey, psId.changeId());
PatchSet ps = psUtil.get(changeNotes, psId);
NotifyResolver.Result notify = ctx.getNotify(changeNotes.getChangeId());
if (notify.shouldNotify()) {
RepoView repoView;
try {
repoView = ctx.getRepoView();
} catch (IOException ex) {
throw new StorageException(String.format("Repository %s not found", ctx.getProject().get()), ex);
}
email.create(notify, changeNotes, ps, user, mailMessage, ctx.getWhen(), comments, null, labelDelta, repoView).sendAsync();
}
commentAdded.fire(ctx.getChangeData(changeNotes), ps, ctx.getAccount(), mailMessage, ImmutableMap.of(), ImmutableMap.of(), ctx.getWhen());
}
use of com.google.gerrit.server.update.RepoView in project gerrit by GerritCodeReview.
the class WorkInProgressOp method postUpdate.
@Override
public void postUpdate(PostUpdateContext ctx) {
stateChanged.fire(ctx.getChangeData(change), ps, ctx.getAccount(), ctx.getWhen());
NotifyResolver.Result notify = ctx.getNotify(change.getId());
if (workInProgress || notify.handling().compareTo(NotifyHandling.OWNER_REVIEWERS) < 0 || !sendEmail) {
return;
}
RepoView repoView;
try {
repoView = ctx.getRepoView();
} catch (IOException ex) {
throw new StorageException(String.format("Repository %s not found", ctx.getProject().get()), ex);
}
email.create(notify, notes, ps, ctx.getIdentifiedUser(), mailMessage, ctx.getWhen(), ImmutableList.of(), mailMessage, ImmutableList.of(), repoView).sendAsync();
}
use of com.google.gerrit.server.update.RepoView in project gerrit by GerritCodeReview.
the class MessageIdGenerator method fromChangeUpdateAndReason.
public MessageId fromChangeUpdateAndReason(RepoView repoView, PatchSet.Id patchsetId, @Nullable String reason) {
String suffix = (reason != null) ? ("-" + reason) : "";
String metaRef = patchsetId.changeId().toRefPrefix() + "meta";
Optional<ObjectId> metaSha1;
try {
metaSha1 = repoView.getRef(metaRef);
} catch (IOException ex) {
throw new StorageException("unable to extract info for Message-Id", ex);
}
return metaSha1.map(optional -> new AutoValue_MessageIdGenerator_MessageId(optional.getName() + suffix)).orElseThrow(() -> new IllegalStateException(metaRef + " doesn't exist"));
}
Aggregations