\r
// reuse some existing repository config settings, if available\r
Config config = r.getConfig()\r
-def mailinglist = config.getString("hooks", null, "mailinglist")\r
-def emailprefix = config.getString("hooks", null, "emailprefix")\r
+def mailinglist = config.getString('hooks', null, 'mailinglist')\r
+def emailprefix = config.getString('hooks', null, 'emailprefix')\r
\r
// set default values\r
def toAddresses = []\r
if (emailprefix == null)\r
- emailprefix = "[Gitblit]"\r
+emailprefix = '"[Gitblit]'\r
\r
if (mailinglist != null) {\r
- def addrs = mailinglist.split("(,|\\s)")\r
+ def addrs = mailinglist.split('(,|\\s)')\r
toAddresses.addAll(addrs)\r
}\r
\r
\r
// special custom cases\r
switch(repository.name) {\r
- case "ex@mple.git":\r
- toAddresses.add "dev-team@somewhere.com"\r
- toAddresses.add "qa-team@somewhere.com"\r
+ case 'ex@mple.git':\r
+ toAddresses.add 'dev-team@somewhere.com'\r
+ toAddresses.add 'qa-team@somewhere.com'\r
break\r
}\r
\r
+// define the summary and commit urls\r
+def summaryUrl\r
+def commitUrl\r
+if (gitblit.getBoolean(Keys.web.mountParameters, true)) {\r
+ summaryUrl = url + '/summary/' + repository.name.replace('/', gitblit.getString(Keys.web.forwardSlashCharacter, '/'))\r
+ commitUrl = url + '/commit/'\r
+} else {\r
+ summaryUrl = url + '/summary?r=' + repository.name\r
+ commitUrl = url + '/commit?h='\r
+}\r
+\r
// construct a simple text summary of the changes contained in the push\r
def commitCount = 0\r
-def changes = ""\r
-def table = { it.id.name[0..8] + " " + it.authorIdent.name.padRight(20, " ") + it.shortMessage }\r
+def changes = ''\r
+def table = { it.authorIdent.name.padRight(25, ' ') + it.shortMessage + "\n$commitUrl" + it.id.name }\r
for (command in commands) {\r
+ def ref = command.refName.substring('refs/heads/'.length())\r
switch (command.type) {\r
case ReceiveCommand.Type.CREATE:\r
def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name)\r
commitCount += commits.size()\r
// new branch commits table\r
- changes += "created ${command.refName}\n\n"\r
- changes += commits.collect(table).join("\n")\r
- changes += "\n"\r
+ changes += "created $ref ($commits.size commits)\n\n"\r
+ changes += commits.collect(table).join('\n\n')\r
+ changes += '\n'\r
break\r
case ReceiveCommand.Type.UPDATE:\r
def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name)\r
commitCount += commits.size()\r
// fast-forward branch commits table\r
- changes += "updated ${command.refName}\n\n"\r
- changes += commits.collect(table).join("\n")\r
- changes += "\n"\r
+ changes += "updated $ref ($commits.size commits)\n\n"\r
+ changes += commits.collect(table).join('\n\n')\r
+ changes += '\n'\r
break\r
case ReceiveCommand.Type.UPDATE_NONFASTFORWARD:\r
def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name)\r
commitCount += commits.size()\r
// non-fast-forward branch commits table\r
- changes += "updated ${command.refName} (NON fast-forward)\n\n"\r
- changes += commits.collect(table).join("\n")\r
- changes += "\n"\r
+ changes += "updated $ref [NON fast-forward] ($commits.size commits)\n\n"\r
+ changes += commits.collect(table).join('\n\n')\r
+ changes += '\n'\r
break\r
case ReceiveCommand.Type.DELETE:\r
// deleted branch\r
- changes += "deleted ${command.refName}\n\n"\r
+ changes += "deleted $ref\n\n"\r
break\r
default:\r
break\r
// close the repository reference\r
r.close()\r
\r
-// build a link to the summary page, either mounted or parameterized\r
-def summaryUrl\r
-if (gitblit.getBoolean(Keys.web.mountParameters, true))\r
- summaryUrl = url + "/summary/" + repository.name.replace("/", gitblit.getString(Keys.web.forwardSlashCharacter, "/"))\r
-else\r
- summaryUrl = url + "/summary?r=" + repository.name\r
-\r
-// create the message body\r
-def msg = """${summaryUrl}\r
-\r
-${changes}"""\r
-\r
// tell Gitblit to send the message (Gitblit filters duplicate addresses)\r
-gitblit.sendEmail("${emailprefix} ${user.username} pushed ${commitCount} commits => ${repository.name}", msg, toAddresses)
\ No newline at end of file
+gitblit.sendEmail("$emailprefix $user.username pushed $commitCount commits => $repository.name", "$summaryUrl\n\n$changes", toAddresses)
\ No newline at end of file