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 | 42 +++++++++++++++++++++++++++--------------- 1 files changed, 27 insertions(+), 15 deletions(-) diff --git a/groovy/sendmail-html.groovy b/groovy/sendmail-html.groovy index 0076e83..1692073 100644 --- a/groovy/sendmail-html.groovy +++ b/groovy/sendmail-html.groovy @@ -197,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" + } } } } @@ -234,7 +238,7 @@ } - def writeCommitTable(commits) { + def writeCommitTable(commits, includeChangedPaths=true) { // Write commits table builder.table('class':"table table-disable-hover") { thead { @@ -250,11 +254,13 @@ for (commit in commits) { writeCommit(commit) - // Write detail on that particular commit - tr('class' : 'noborder') { - 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) } + } + } } } } @@ -364,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() { @@ -441,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() -- Gitblit v1.9.1