From 7c643b65f3613e30a14e8e9decc92fddb8bfd654 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 01 Jul 2011 17:42:56 -0400
Subject: [PATCH] Documentation. Include LICENSE and NOTICE files in both builds.
---
src/com/gitblit/utils/TicgitUtils.java | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/com/gitblit/utils/TicgitUtils.java b/src/com/gitblit/utils/TicgitUtils.java
index 914b813..48e8558 100644
--- a/src/com/gitblit/utils/TicgitUtils.java
+++ b/src/com/gitblit/utils/TicgitUtils.java
@@ -21,6 +21,7 @@
import java.util.List;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,7 +38,7 @@
RefModel ticgitBranch = null;
try {
// search for ticgit branch in local heads
- for (RefModel ref : JGitUtils.getLocalBranches(r, -1)) {
+ for (RefModel ref : JGitUtils.getLocalBranches(r, false, -1)) {
if (ref.displayName.endsWith("ticgit")) {
ticgitBranch = ref;
break;
@@ -46,7 +47,7 @@
// search for ticgit branch in remote heads
if (ticgitBranch == null) {
- for (RefModel ref : JGitUtils.getRemoteBranches(r, -1)) {
+ for (RefModel ref : JGitUtils.getRemoteBranches(r, false, -1)) {
if (ref.displayName.endsWith("ticgit")) {
ticgitBranch = ref;
break;
@@ -61,7 +62,11 @@
public static List<TicketModel> getTickets(Repository r) {
RefModel ticgitBranch = getTicketsBranch(r);
- List<PathModel> paths = JGitUtils.getFilesInPath(r, null, ticgitBranch.commit);
+ if (ticgitBranch == null) {
+ return null;
+ }
+ RevCommit commit = (RevCommit) ticgitBranch.referencedObject;
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, null, commit);
List<TicketModel> tickets = new ArrayList<TicketModel>();
for (PathModel ticketFolder : paths) {
if (ticketFolder.isTree()) {
@@ -94,11 +99,10 @@
}
private static void readTicketContents(Repository r, RefModel ticketsBranch, TicketModel ticket) {
- List<PathModel> ticketFiles = JGitUtils
- .getFilesInPath(r, ticket.name, ticketsBranch.commit);
+ RevCommit commit = (RevCommit) ticketsBranch.referencedObject;
+ List<PathModel> ticketFiles = JGitUtils.getFilesInPath(r, ticket.name, commit);
for (PathModel file : ticketFiles) {
- String content = JGitUtils.getRawContentAsString(r, ticketsBranch.commit, file.path)
- .trim();
+ String content = JGitUtils.getStringContent(r, commit.getTree(), file.path).trim();
if (file.name.equals("TICKET_ID")) {
ticket.id = content;
} else if (file.name.equals("TITLE")) {
@@ -112,7 +116,7 @@
Comment c = new Comment(file.name, content);
ticket.comments.add(c);
} catch (ParseException e) {
- e.printStackTrace();
+ LOGGER.error("Failed to parse ticket comment", e);
}
} else if (chunks[0].equals("TAG")) {
if (content.startsWith("TAG_")) {
@@ -126,13 +130,5 @@
}
}
Collections.sort(ticket.comments);
- }
-
- public static String getTicketContent(Repository r, String filePath) {
- RefModel ticketsBranch = getTicketsBranch(r);
- if (ticketsBranch != null) {
- return JGitUtils.getRawContentAsString(r, ticketsBranch.commit, filePath);
- }
- return "";
}
}
--
Gitblit v1.9.1