Include full commit message in event stream data
The full commit message of the change's latest patch set is now included in the data sent to the event stream. Change-Id: Ie18d678bb61cfd0213b9ebc09d59654ede2b74c8
This commit is contained in:
@@ -45,12 +45,14 @@ import com.google.gerrit.server.data.RefUpdateAttribute;
|
|||||||
import com.google.gerrit.server.data.SubmitLabelAttribute;
|
import com.google.gerrit.server.data.SubmitLabelAttribute;
|
||||||
import com.google.gerrit.server.data.SubmitRecordAttribute;
|
import com.google.gerrit.server.data.SubmitRecordAttribute;
|
||||||
import com.google.gerrit.server.data.TrackingIdAttribute;
|
import com.google.gerrit.server.data.TrackingIdAttribute;
|
||||||
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.patch.PatchList;
|
import com.google.gerrit.server.patch.PatchList;
|
||||||
import com.google.gerrit.server.patch.PatchListCache;
|
import com.google.gerrit.server.patch.PatchListCache;
|
||||||
import com.google.gerrit.server.patch.PatchListEntry;
|
import com.google.gerrit.server.patch.PatchListEntry;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||||
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.gwtorm.server.SchemaFactory;
|
import com.google.gwtorm.server.SchemaFactory;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -78,19 +80,24 @@ public class EventFactory {
|
|||||||
private final SchemaFactory<ReviewDb> schema;
|
private final SchemaFactory<ReviewDb> schema;
|
||||||
private final PatchSetInfoFactory psInfoFactory;
|
private final PatchSetInfoFactory psInfoFactory;
|
||||||
private final PersonIdent myIdent;
|
private final PersonIdent myIdent;
|
||||||
|
private final Provider<ReviewDb> db;
|
||||||
|
private final GitRepositoryManager repoManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
EventFactory(AccountCache accountCache,
|
EventFactory(AccountCache accountCache,
|
||||||
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
@CanonicalWebUrl @Nullable Provider<String> urlProvider,
|
||||||
PatchSetInfoFactory psif,
|
PatchSetInfoFactory psif,
|
||||||
PatchListCache patchListCache, SchemaFactory<ReviewDb> schema,
|
PatchListCache patchListCache, SchemaFactory<ReviewDb> schema,
|
||||||
@GerritPersonIdent PersonIdent myIdent) {
|
@GerritPersonIdent PersonIdent myIdent,
|
||||||
|
Provider<ReviewDb> db, GitRepositoryManager repoManager) {
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.urlProvider = urlProvider;
|
this.urlProvider = urlProvider;
|
||||||
this.patchListCache = patchListCache;
|
this.patchListCache = patchListCache;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
this.psInfoFactory = psif;
|
this.psInfoFactory = psif;
|
||||||
this.myIdent = myIdent;
|
this.myIdent = myIdent;
|
||||||
|
this.db = db;
|
||||||
|
this.repoManager = repoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,6 +115,12 @@ public class EventFactory {
|
|||||||
a.id = change.getKey().get();
|
a.id = change.getKey().get();
|
||||||
a.number = change.getId().toString();
|
a.number = change.getId().toString();
|
||||||
a.subject = change.getSubject();
|
a.subject = change.getSubject();
|
||||||
|
try {
|
||||||
|
a.commitMessage = new ChangeData(change).commitMessage(repoManager, db);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error while getting full commit message for"
|
||||||
|
+ " change " + a.number);
|
||||||
|
}
|
||||||
a.url = getChangeUrl(change);
|
a.url = getChangeUrl(change);
|
||||||
a.owner = asAccountAttribute(change.getOwner());
|
a.owner = asAccountAttribute(change.getOwner());
|
||||||
a.status = change.getStatus();
|
a.status = change.getStatus();
|
||||||
@@ -118,7 +131,8 @@ public class EventFactory {
|
|||||||
* Create a RefUpdateAttribute for the given old ObjectId, new ObjectId, and
|
* Create a RefUpdateAttribute for the given old ObjectId, new ObjectId, and
|
||||||
* branch that is suitable for serialization to JSON.
|
* branch that is suitable for serialization to JSON.
|
||||||
*
|
*
|
||||||
* @param refUpdate
|
* @param oldId
|
||||||
|
* @param newId
|
||||||
* @param refName
|
* @param refName
|
||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user