From ed32130b4d355c7925deb4b7c4300d41509770f0 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Sat, 22 Dec 2012 00:26:10 -0500
Subject: [PATCH] Update to JGit 2.2.0

---
 groovy/sendmail-html.groovy |   85 ++++++++++++++++++++++++++----------------
 1 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/groovy/sendmail-html.groovy b/groovy/sendmail-html.groovy
index 72de106..1692073 100644
--- a/groovy/sendmail-html.groovy
+++ b/groovy/sendmail-html.groovy
@@ -115,7 +115,7 @@
 }
 
 // add all mailing lists defined in gitblit.properties or web.xml
-toAddresses.addAll(gitblit.getStrings(Keys.mail.mailingLists))
+toAddresses.addAll(GitBlit.getStrings(Keys.mail.mailingLists))
 
 // add all team mailing lists
 def teams = gitblit.getRepositoryTeams(repository)
@@ -154,6 +154,7 @@
     def mountParameters
 	def forwardSlashChar
 	def includeGravatar
+	def shortCommitIdLength
     def commitCount = 0
     def commands
     def writer = new StringWriter();
@@ -163,6 +164,10 @@
         builder.style(type:"text/css", '''
     .table td {
         vertical-align: middle;
+    }
+    tr.noborder td {
+        border: none;
+        padding-top: 0px;
     }
     .gravatar-column {
         width: 5%; 
@@ -176,14 +181,14 @@
     .status-column {
         width: 10%;
     }
-.table-disable-hover.table tbody tr:hover td,
-.table-disable-hover.table tbody tr:hover th {
-    background-color: inherit;
-}
-.table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,
-.table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {
-  background-color: #f9f9f9;
-}
+    .table-disable-hover.table tbody tr:hover td,
+    .table-disable-hover.table tbody tr:hover th {
+        background-color: inherit;
+    }
+    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover td,
+    .table-disable-hover.table-striped tbody tr:nth-child(odd):hover th {
+      background-color: #f9f9f9;
+    }
     ''')
     }
 
@@ -192,7 +197,11 @@
 			builder.span('class':'project') {
 				mkp.yield "$type "
 				span('class': 'repository', name )
-				mkp.yield " $action ($number commits)"
+				if (number > 0) {
+					mkp.yield " $action ($number commits)"
+				} else {
+					mkp.yield " $action"
+				}
 			}
         }
     }
@@ -229,7 +238,7 @@
 
     }
 
-    def writeCommitTable(commits) {
+    def writeCommitTable(commits, includeChangedPaths=true) {
         // Write commits table
         builder.table('class':"table table-disable-hover") {
             thead {
@@ -245,18 +254,20 @@
                 for (commit in commits) {
                     writeCommit(commit)
 
-                    // Write detail on that particular commit
-                    tr {
-                        td (colspan: includeGravatar ? 3 : 2)
-                        td (colspan:2) { writeStatusTable(commit) }
-                    }
+					if (includeChangedPaths) {
+						// Write detail on that particular commit
+						tr('class' : 'noborder') {
+							td (colspan: includeGravatar ? 3 : 2)
+							td (colspan:2) { writeStatusTable(commit) }
+						}
+					}
                 }
             }
         }
     }
 
     def writeCommit(commit) {
-        def abbreviated = repository.newObjectReader().abbreviate(commit.id, 8).name()
+        def abbreviated = repository.newObjectReader().abbreviate(commit.id, shortCommitIdLength).name()
         def author = commit.authorIdent.name
         def email = commit.authorIdent.emailAddress
         def message = commit.shortMessage
@@ -288,7 +299,7 @@
             writeStatusLabel("addition", "addition")
         }
         builder.td {
-            a(href:blobDiffUrl(id, header.newPath)) { span(style:'font-family: monospace;', header.newPath) }
+            a(href:blobDiffUrl(id, header.newPath), header.newPath)
         }
     }
 
@@ -297,7 +308,7 @@
             writeStatusLabel("rename", "rename")
         }
         builder.td() {
-            a(href:blobDiffUrl(id, header.newPath)) { span(style : "font-family: monospace; ", header.oldPath + " copied to " + header.newPath) }
+            a(href:blobDiffUrl(id, header.newPath), header.oldPath + " copied to " + header.newPath)
         }
     }
 
@@ -306,7 +317,7 @@
             writeStatusLabel("deletion", "deletion")
         }
         builder.td() {
-            a(href:blobDiffUrl(id, header.oldPath)) { span(style : "font-family: monospace; ", header.oldPath) }
+            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)
         }
     }
 
@@ -315,7 +326,7 @@
 			writeStatusLabel("modification", "modification")
         }
         builder.td() {
-            a(href:blobDiffUrl(id, header.oldPath)) { span(style : "font-family: monospace; ", header.oldPath) }
+            a(href:blobDiffUrl(id, header.oldPath), header.oldPath)
         }
     }
 
@@ -324,7 +335,9 @@
              writeStatusLabel("rename", "rename")
         }
         builder.td() {
-            a(href:blobDiffUrl(id, header.newPath)) { span(style : "font-family: monospace; ", header.olPath + " -> " + header.newPath) }
+            mkp.yield header.oldPath
+			mkp.yieldUnescaped "<b> -&rt; </b>"
+			a(href:blobDiffUrl(id, header.newPath),  header.newPath)
         }
     }
 
@@ -357,14 +370,15 @@
         formatter.setDiffComparator(RawTextComparator.DEFAULT);
 
         def diffs
-        RevWalk rw = new RevWalk(repository);
+		RevWalk rw = new RevWalk(repository)
         if (commit.parentCount > 0) {
-            RevCommit parent = commit.parents[0]
+			RevCommit parent = rw.parseCommit(commit.parents[0].id)
             diffs = formatter.scan(parent.tree, commit.tree)
         } else {
             diffs = formatter.scan(new EmptyTreeIterator(),
                                    new CanonicalTreeParser(null, rw.objectReader, commit.tree))
         }
+		rw.dispose()
         // Write status table
         builder.table('class':"plain") {
             tbody() {
@@ -413,6 +427,7 @@
             head {
                 link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap.css")
                 link(rel:"stylesheet", href:"${url}/gitblit.css")
+				link(rel:"stylesheet", href:"${url}/bootstrap/css/bootstrap-responsive.css")
                 writeStyle()
             }
             body {
@@ -433,12 +448,17 @@
 
                     switch (command.type) {
                         case ReceiveCommand.Type.CREATE:
-                            def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()
-                            commitCount += commits.size()
-                            // new branch
-                            // Write header
-                            writeBranchTitle(refType, ref, "created", commits.size())
-                            writeCommitTable(commits)
+							def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()
+							commitCount += commits.size()
+							if (refType == 'Branch') {
+								// new branch
+								writeBranchTitle(refType, ref, "created", commits.size())
+								writeCommitTable(commits, true)
+							} else {
+								// new tag
+								writeBranchTitle(refType, ref, "created", 0)
+								writeCommitTable(commits, false)
+							}
                             break
                         case ReceiveCommand.Type.UPDATE:
                             def commits = JGitUtils.getRevLog(repository, command.oldId.name, command.newId.name).reverse()
@@ -480,8 +500,9 @@
 mailWriter.forwardSlashChar = forwardSlashChar
 mailWriter.commands = commands
 mailWriter.url = url
-mailWriter.mountParameters = gitblit.getBoolean(Keys.web.mountParameters, true)
-mailWriter.includeGravatar = gitblit.getBoolean(Keys.web.allowGravatar, true)
+mailWriter.mountParameters = GitBlit.getBoolean(Keys.web.mountParameters, true)
+mailWriter.includeGravatar = GitBlit.getBoolean(Keys.web.allowGravatar, true)
+mailWriter.shortCommitIdLength = GitBlit.getInteger(Keys.web.shortCommitIdLength, 8)
 
 def content = mailWriter.write()
 

--
Gitblit v1.9.1