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 StringcheckAndSanitizeCommitMessage(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.ObjectIdgenerateChangeId()static Change.KeygenerateKey()static Optional<String>getChangeIdFromCommitMessageFooter(String commitMessage)Return the value of Change-Id from the commit message footer.static StringgetChangeIdFromObjectId(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.- 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:
Optionalvalue of Change-Id footer in the commit message.
-
-