Created
February 18, 2012 21:02
-
-
Save foerster/1861014 to your computer and use it in GitHub Desktop.
Gerrit - state change email subjects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Copyright (C) 2010 The Android Open Source Project | |
## | |
## Licensed under the Apache License, Version 2.0 (the "License"); | |
## you may not use this file except in compliance with the License. | |
## You may obtain a copy of the License at | |
## | |
## http://www.apache.org/licenses/LICENSE-2.0 | |
## | |
## Unless required by applicable law or agreed to in writing, software | |
## distributed under the License is distributed on an "AS IS" BASIS, | |
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
## See the License for the specific language governing permissions and | |
## limitations under the License. | |
## | |
## | |
## Template Type: | |
## ------------- | |
## This is a velocity mail template, see: http://velocity.apache.org and the | |
## gerrit-docs:config-mail.txt for more info on modifying gerrit mail templates. | |
## | |
## Template File Names and extensions: | |
## ---------------------------------- | |
## Gerrit will use templates ending in ".vm" but will ignore templates ending | |
## in ".vm.example". If a .vm template does not exist, the default internal | |
## gerrit template which is the same as the .vm.example will be used. If you | |
## want to override the default template, copy the .vm.exmaple file to a .vm | |
## file and edit it appropriately. | |
## | |
## This Template: | |
## -------------- | |
## The ChangeSubject.vm template will determine the contents of the email | |
## subject line for ALL emails related to changes. | |
## | |
#macro(elipses $length $str) | |
#if($str.length() > $length)${str.substring(0,$length)}...#else$str#end | |
#end | |
#if( $messageClass == "comment" ) | |
#set( $subject_prefix = "Comments" ) | |
#elseif( $messageClass == "merged" ) | |
#set( $subject_prefix = "Merged" ) | |
#elseif( $messageClass == "newchange" ) | |
#set( $subject_prefix = "Review Request" ) | |
#elseif( $messageClass == "newpatchset" ) | |
#set( $subject_prefix = "New Patchset" ) | |
#elseif( $messageClass == "abandon" ) | |
#set( $subject_prefix = "Abandoned" ) | |
#elseif( $messageClass == "restore" ) | |
#set( $subject_prefix = "Restored" ) | |
#elseif( $messageClass == "revert" ) | |
#set( $subject_prefix = "Reverted" ) | |
#elseif( $messageClass == "merge-failed" ) | |
#set( $subject_prefix = "Merge Failed" ) | |
#else | |
#set( $subject_prefix = "" ) | |
#end | |
$subject_prefix - $projectName.replaceAll('/.*/', '...')[$branch.shortName]: #elipses(60, $change.subject) |
Updated with revert and restore (thanks to @GLundh)
Foerster: If you have had issues with subjects being prefixed with white space, please check my updated gist fork.
- Thanks for the awesome template.
Thanks for the heads up. The version I was using on my server actually didn't have the newlines. I only added the newlines to make the file more readable when I posted the template. Oops!
Fork updated to allow different subjects for New Changes and Review Requests.
The line
$subject_prefix - $projectName.replaceAll('/.*/', '...')[$branch.shortName]: #elipses(60, $change.subject)
does not work for me in gerrit 2.10 (it causes some Exception), there are some problems with the '['-character.
I changed it to the following, this makes it work again:
#set( $affected_branch = "[$branch.shortName]" )
$subject_prefix - $projectName.replaceAll('/.*/', '...')$affected_branch: #ellipsis(60, $change.subject)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This allows gerrit to send emails with helpful subject lines.
Rather than all emails having a subject of "Change in projectName[master]..."
This template will instead fill in the reason for the email into the subject as: "Review Request - projectName[master]..."