Package com.google.gerrit.server.util
Class CommitMessageUtil
- java.lang.Object
-
- com.google.gerrit.server.util.CommitMessageUtil
-
public class CommitMessageUtil extends Object
Utility functions to manipulate commit messages.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
checkAndSanitizeCommitMessage(String commitMessage)
Checks for invalid (empty or containing \0) commit messages and appends a newline character to the commit message.static org.eclipse.jgit.lib.ObjectId
generateChangeId()
static Change.Key
generateKey()
static Optional<String>
getChangeIdFromCommitMessageFooter(String commitMessage)
Return the value of Change-Id from the commit message footer.static String
getChangeIdFromObjectId(org.eclipse.jgit.lib.ObjectId objectId)
-
-
-
Method Detail
-
checkAndSanitizeCommitMessage
public static String checkAndSanitizeCommitMessage(String commitMessage) throws BadRequestException
Checks for invalid (empty or containing \0) commit messages and appends a newline character to the commit message.- Returns:
- the trimmed message with a trailing newline character
- Throws:
BadRequestException
- if the commit message is null or empty
-
generateChangeId
public static org.eclipse.jgit.lib.ObjectId generateChangeId()
-
generateKey
public static Change.Key generateKey()
-
getChangeIdFromObjectId
public static String getChangeIdFromObjectId(org.eclipse.jgit.lib.ObjectId objectId)
-
getChangeIdFromCommitMessageFooter
public static Optional<String> getChangeIdFromCommitMessageFooter(String commitMessage)
Return the value of Change-Id from the commit message footer.The behaviour matches
ChangeIdUtil
. If more than one matching Change-Id footer is found, return the value of the last one.- Parameters:
commitMessage
- commit message to get Change-Id from.- Returns:
Optional
value of Change-Id footer in the commit message.
-
-