Package com.google.gerrit.server
Class ChangeMessagesUtil
- java.lang.Object
-
- com.google.gerrit.server.ChangeMessagesUtil
-
public class ChangeMessagesUtil extends Object
Utility functions to manipulateChangeMessage
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
AUTOGENERATED_BY_GERRIT_TAG_PREFIX
static String
AUTOGENERATED_TAG_PREFIX
static String
TAG_ABANDON
static String
TAG_CHERRY_PICK_CHANGE
static String
TAG_DELETE_ASSIGNEE
static String
TAG_DELETE_REVIEWER
static String
TAG_DELETE_VOTE
static String
TAG_MERGED
static String
TAG_MOVE
static String
TAG_RESTORE
static String
TAG_REVERT
static String
TAG_SET_ASSIGNEE
static String
TAG_SET_DESCRIPTION
static String
TAG_SET_HASHTAGS
static String
TAG_SET_PRIVATE
static String
TAG_SET_READY
static String
TAG_SET_TOPIC
static String
TAG_SET_WIP
static String
TAG_UNSET_PRIVATE
static String
TAG_UPDATE_ATTENTION_SET
static String
TAG_UPLOADED_PATCH_SET
static String
TAG_UPLOADED_WIP_PATCH_SET
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<ChangeMessage>
byChange(ChangeNotes notes)
ReturnsChangeMessage
s fromChangeNotes
, loadsChangeNotes
from data storage (cache or NoteDB), if it was not loaded yet.static ChangeMessageInfo
createChangeMessageInfo(ChangeMessage message, AccountLoader accountLoader)
ChangeMessageInfo
createChangeMessageInfoWithReplacedTemplates(ChangeMessage message, AccountLoader accountLoader)
ChangeMessage
is served in template form toChangeApi
.static boolean
isAutogenerated(String tag)
Determines whether the tag starts with the autogenerated prefixstatic boolean
isAutogeneratedByGerrit(String tag)
void
replaceChangeMessage(ChangeUpdate update, String targetMessageId, String newMessage)
Replace an existing change message with the provided new message.String
setChangeMessage(ChangeUpdate update, String messageTemplate, String tag)
SetsmessageTemplate
andtag
, that should be applied by theupdate
.String
setChangeMessage(ChangeContext ctx, String messageTemplate, String tag)
static String
uploadedPatchSetTag(boolean workInProgress)
-
-
-
Field Detail
-
AUTOGENERATED_TAG_PREFIX
public static final String AUTOGENERATED_TAG_PREFIX
- See Also:
- Constant Field Values
-
AUTOGENERATED_BY_GERRIT_TAG_PREFIX
public static final String AUTOGENERATED_BY_GERRIT_TAG_PREFIX
- See Also:
- Constant Field Values
-
TAG_ABANDON
public static final String TAG_ABANDON
- See Also:
- Constant Field Values
-
TAG_CHERRY_PICK_CHANGE
public static final String TAG_CHERRY_PICK_CHANGE
- See Also:
- Constant Field Values
-
TAG_DELETE_ASSIGNEE
public static final String TAG_DELETE_ASSIGNEE
- See Also:
- Constant Field Values
-
TAG_DELETE_REVIEWER
public static final String TAG_DELETE_REVIEWER
- See Also:
- Constant Field Values
-
TAG_DELETE_VOTE
public static final String TAG_DELETE_VOTE
- See Also:
- Constant Field Values
-
TAG_MERGED
public static final String TAG_MERGED
- See Also:
- Constant Field Values
-
TAG_MOVE
public static final String TAG_MOVE
- See Also:
- Constant Field Values
-
TAG_RESTORE
public static final String TAG_RESTORE
- See Also:
- Constant Field Values
-
TAG_REVERT
public static final String TAG_REVERT
- See Also:
- Constant Field Values
-
TAG_SET_ASSIGNEE
public static final String TAG_SET_ASSIGNEE
- See Also:
- Constant Field Values
-
TAG_UPDATE_ATTENTION_SET
public static final String TAG_UPDATE_ATTENTION_SET
- See Also:
- Constant Field Values
-
TAG_SET_DESCRIPTION
public static final String TAG_SET_DESCRIPTION
- See Also:
- Constant Field Values
-
TAG_SET_HASHTAGS
public static final String TAG_SET_HASHTAGS
- See Also:
- Constant Field Values
-
TAG_SET_PRIVATE
public static final String TAG_SET_PRIVATE
- See Also:
- Constant Field Values
-
TAG_SET_READY
public static final String TAG_SET_READY
- See Also:
- Constant Field Values
-
TAG_SET_TOPIC
public static final String TAG_SET_TOPIC
- See Also:
- Constant Field Values
-
TAG_SET_WIP
public static final String TAG_SET_WIP
- See Also:
- Constant Field Values
-
TAG_UNSET_PRIVATE
public static final String TAG_UNSET_PRIVATE
- See Also:
- Constant Field Values
-
TAG_UPLOADED_PATCH_SET
public static final String TAG_UPLOADED_PATCH_SET
- See Also:
- Constant Field Values
-
TAG_UPLOADED_WIP_PATCH_SET
public static final String TAG_UPLOADED_WIP_PATCH_SET
- See Also:
- Constant Field Values
-
-
Method Detail
-
setChangeMessage
public String setChangeMessage(ChangeUpdate update, String messageTemplate, String tag)
SetsmessageTemplate
andtag
, that should be applied by theupdate
.The
messageTemplate
is persisted in storage and should not contain user identifiable information. SeeChangeMessage
.- Parameters:
update
- update that setsmessageTemplate
.messageTemplate
- message in template form, that should be applied by the update.tag
- tag that should be applied by the update.- Returns:
- message built from
messageTemplate
. Templates are replaced, so it might contain user identifiable information.
-
setChangeMessage
public String setChangeMessage(ChangeContext ctx, String messageTemplate, String tag)
-
uploadedPatchSetTag
public static String uploadedPatchSetTag(boolean workInProgress)
-
byChange
public List<ChangeMessage> byChange(ChangeNotes notes)
ReturnsChangeMessage
s fromChangeNotes
, loadsChangeNotes
from data storage (cache or NoteDB), if it was not loaded yet.
-
replaceChangeMessage
public void replaceChangeMessage(ChangeUpdate update, String targetMessageId, String newMessage)
Replace an existing change message with the provided new message.The ID of a change message is different between NoteDb and ReviewDb. In NoteDb, it's the commit SHA-1, but in ReviewDb it was generated randomly. Taking the target message as an index rather than an ID allowed us to delete the message from both NoteDb and ReviewDb.
- Parameters:
update
- change update.targetMessageId
- the id of the target change message.newMessage
- the new message which is going to replace the old.
-
isAutogenerated
public static boolean isAutogenerated(String tag)
Determines whether the tag starts with the autogenerated prefix- Parameters:
tag
- value of a tag, or null.
-
isAutogeneratedByGerrit
public static boolean isAutogeneratedByGerrit(String tag)
-
createChangeMessageInfo
public static ChangeMessageInfo createChangeMessageInfo(ChangeMessage message, AccountLoader accountLoader)
-
createChangeMessageInfoWithReplacedTemplates
public ChangeMessageInfo createChangeMessageInfoWithReplacedTemplates(ChangeMessage message, AccountLoader accountLoader)
ChangeMessage
is served in template form toChangeApi
. Serve message with replaced templates to the legacyChangeMessageApi
endpoints. TODO(mariasavtchouk): remove this, afterChangeMessageApi
is deprecated (gate with experiment).
-
-