From 9802a766a28bfcb0ae01494ebfa1cbeb11e71809 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 17 Apr 2011 12:06:29 -0400 Subject: [PATCH] Rename ticgit integration to tickets. The current ticgit implementation is based on ticgit.net, a BSD implementation for C#. Jeff Welling advises using commit bf57b032e030bd16a7b2 (2009-01-27) from ticgit as the last MIT licensed commit. A more complete implementation will be based on this version of the original Ruby sources. It remains unclear if I will support using the "ticgit" branch name or not. I purposefully haven't looked at any of the GPL improvements by Jeff, but I can see from the readme at GitHub that he has renamed the branch to "ticgit-ng" which I have no plans on supporting as I do not want to taint GitBlit with GPL code. --- gitblit.properties | 8 ++-- src/com/gitblit/tests/JGitUtilsTest.java | 6 +-- src/com/gitblit/utils/JGitUtils.java | 46 +++++++++---------- src/com/gitblit/wicket/GitBlitWebApp.java | 10 ++-- .../gitblit/wicket/GitBlitWebApp.properties | 2 +- .../{TicGitTicket.java => TicketModel.java} | 8 ++-- ...{TicGitTicketPage.html => TicketPage.html} | 0 ...{TicGitTicketPage.java => TicketPage.java} | 10 ++-- .../{TicGitPage.html => TicketsPage.html} | 0 .../{TicGitPage.java => TicketsPage.java} | 20 ++++---- .../gitblit/wicket/panels/HistoryPanel.java | 1 + .../gitblit/wicket/panels/PageLinksPanel.java | 18 ++++---- 12 files changed, 65 insertions(+), 64 deletions(-) rename src/com/gitblit/wicket/models/{TicGitTicket.java => TicketModel.java} (84%) rename src/com/gitblit/wicket/pages/{TicGitTicketPage.html => TicketPage.html} (100%) rename src/com/gitblit/wicket/pages/{TicGitTicketPage.java => TicketPage.java} (86%) rename src/com/gitblit/wicket/pages/{TicGitPage.html => TicketsPage.html} (100%) rename src/com/gitblit/wicket/pages/{TicGitPage.java => TicketsPage.java} (66%) diff --git a/gitblit.properties b/gitblit.properties index a4828108..93183eb7 100644 --- a/gitblit.properties +++ b/gitblit.properties @@ -103,11 +103,11 @@ regex.global.changeid = \\b(Change-Id:\\s*)([A-Za-z0-9]*)\\b!!!Bug-Id: $3 -# Enable ticgit pages for all repositories (if ticgit branch is present) -ticgit.global = false +# Enable tickets pages for all repositories (if ticgit branch is present) +tickets.global = false -# Enable ticgit pages for specified repository (if ticgit branch is present) -#ticgit.myrepository = true +# Enable tickets pages for specified repository (if ticgit branch is present) +#tickets.myrepository = true # # Server Settings diff --git a/src/com/gitblit/tests/JGitUtilsTest.java b/src/com/gitblit/tests/JGitUtilsTest.java index c77aaaf1..b6b497f0 100644 --- a/src/com/gitblit/tests/JGitUtilsTest.java +++ b/src/com/gitblit/tests/JGitUtilsTest.java @@ -17,7 +17,7 @@ import org.eclipse.jgit.storage.file.FileRepository; import com.gitblit.utils.JGitUtils; import com.gitblit.wicket.models.PathModel; import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.models.TicGitTicket; +import com.gitblit.wicket.models.TicketModel; public class JGitUtilsTest extends TestCase { @@ -72,9 +72,9 @@ public class JGitUtilsTest extends TestCase { public void testTicGit() throws Exception { Repository r = new FileRepository(new File(repositoriesFolder, "ticgit") + "/" + Constants.DOT_GIT); - RefModel ticgit = JGitUtils.getTicGitBranch(r); + RefModel ticgit = JGitUtils.getTicketsBranch(r); assertTrue("Ticgit branch does not exist!", ticgit != null); - List tickets = JGitUtils.getTicGitTickets(r); + List tickets = JGitUtils.getTickets(r); assertTrue("No tickets found!", tickets.size() > 0); r.close(); } diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 7128f722..075ad81b 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -46,8 +46,8 @@ import org.slf4j.LoggerFactory; import com.gitblit.wicket.models.Metric; import com.gitblit.wicket.models.PathModel; import com.gitblit.wicket.models.RefModel; -import com.gitblit.wicket.models.TicGitTicket; -import com.gitblit.wicket.models.TicGitTicket.Comment; +import com.gitblit.wicket.models.TicketModel; +import com.gitblit.wicket.models.TicketModel.Comment; public class JGitUtils { @@ -614,12 +614,12 @@ public class JGitUtils { return metrics; } - public static RefModel getTicGitBranch(Repository r) { + public static RefModel getTicketsBranch(Repository r) { RefModel ticgitBranch = null; try { // search for ticgit branch in local heads for (RefModel ref : getLocalBranches(r, -1)) { - if (ref.getDisplayName().endsWith("ticgit") || ref.getDisplayName().endsWith("ticgit-ng")) { + if (ref.getDisplayName().endsWith("ticgit")) { ticgitBranch = ref; break; } @@ -628,7 +628,7 @@ public class JGitUtils { // search for ticgit branch in remote heads if (ticgitBranch == null) { for (RefModel ref : getRemoteBranches(r, -1)) { - if (ref.getDisplayName().endsWith("ticgit") || ref.getDisplayName().endsWith("ticgit-ng")) { + if (ref.getDisplayName().endsWith("ticgit")) { ticgitBranch = ref; break; } @@ -640,18 +640,18 @@ public class JGitUtils { return ticgitBranch; } - public static List getTicGitTickets(Repository r) { - RefModel ticgitBranch = getTicGitBranch(r); + public static List getTickets(Repository r) { + RefModel ticgitBranch = getTicketsBranch(r); List paths = getFilesInPath(r, null, ticgitBranch.getCommit()); - List tickets = new ArrayList(); + List tickets = new ArrayList(); for (PathModel ticketFolder : paths) { if (ticketFolder.isTree()) { try { - TicGitTicket t = new TicGitTicket(ticketFolder.name); + TicketModel t = new TicketModel(ticketFolder.name); readTicketContents(r, ticgitBranch, t); tickets.add(t); } catch (Throwable t) { - LOGGER.error("Failed to get a ticgit ticket!", t); + LOGGER.error("Failed to get a ticket!", t); } } } @@ -660,24 +660,24 @@ public class JGitUtils { return tickets; } - public static TicGitTicket getTicGitTicket(Repository r, String ticketFolder) { - RefModel ticgitBranch = getTicGitBranch(r); - if (ticgitBranch != null) { + public static TicketModel getTicket(Repository r, String ticketFolder) { + RefModel ticketsBranch = getTicketsBranch(r); + if (ticketsBranch != null) { try { - TicGitTicket ticket = new TicGitTicket(ticketFolder); - readTicketContents(r, ticgitBranch, ticket); + TicketModel ticket = new TicketModel(ticketFolder); + readTicketContents(r, ticketsBranch, ticket); return ticket; } catch (Throwable t) { - LOGGER.error("Failed to get ticgit ticket " + ticketFolder, t); + LOGGER.error("Failed to get ticket " + ticketFolder, t); } } return null; } - private static void readTicketContents(Repository r, RefModel ticgitBranch, TicGitTicket ticket) { - List ticketFiles = getFilesInPath(r, ticket.name, ticgitBranch.getCommit()); + private static void readTicketContents(Repository r, RefModel ticketsBranch, TicketModel ticket) { + List ticketFiles = getFilesInPath(r, ticket.name, ticketsBranch.getCommit()); for (PathModel file : ticketFiles) { - String content = getRawContentAsString(r, ticgitBranch.getCommit(), file.path).trim(); + String content = getRawContentAsString(r, ticketsBranch.getCommit(), file.path).trim(); if (file.name.equals("TICKET_ID")) { ticket.id = content; } else if (file.name.equals("TITLE")) { @@ -707,10 +707,10 @@ public class JGitUtils { Collections.sort(ticket.comments); } - public static String getTicGitContent(Repository r, String filePath) { - RefModel ticgitBranch = getTicGitBranch(r); - if (ticgitBranch != null) { - return getRawContentAsString(r, ticgitBranch.getCommit(), filePath); + public static String getTicketContent(Repository r, String filePath) { + RefModel ticketsBranch = getTicketsBranch(r); + if (ticketsBranch != null) { + return getRawContentAsString(r, ticketsBranch.getCommit(), filePath); } return ""; } diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 28f62625..74057c99 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -25,8 +25,8 @@ import com.gitblit.wicket.pages.RepositoriesPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagPage; import com.gitblit.wicket.pages.TagsPage; -import com.gitblit.wicket.pages.TicGitPage; -import com.gitblit.wicket.pages.TicGitTicketPage; +import com.gitblit.wicket.pages.TicketsPage; +import com.gitblit.wicket.pages.TicketPage; import com.gitblit.wicket.pages.TreePage; public class GitBlitWebApp extends WebApplication { @@ -63,9 +63,9 @@ public class GitBlitWebApp extends WebApplication { mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" })); mount(new MixedParamUrlCodingStrategy("/history", HistoryPage.class, new String[] { "r", "h", "f" })); - // setup ticgit urls - mount(new MixedParamUrlCodingStrategy("/ticgit", TicGitPage.class, new String[] { "r" })); - mount(new MixedParamUrlCodingStrategy("/ticgittkt", TicGitTicketPage.class, new String[] { "r", "h", "f" })); + // setup ticket urls + mount(new MixedParamUrlCodingStrategy("/tickets", TicketsPage.class, new String[] { "r" })); + mount(new MixedParamUrlCodingStrategy("/ticket", TicketPage.class, new String[] { "r", "h", "f" })); // setup login/logout urls, if we are using authentication if (useAuthentication) { diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 033742eb..331fc294 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -34,7 +34,7 @@ gb.ticket = ticket gb.newRepository = new repository gb.newUser = new user gb.commitdiff = commitdiff -gb.ticgit = ticgit +gb.tickets = tickets gb.pageFirst = first gb.pagePrevious prev gb.pageNext = next diff --git a/src/com/gitblit/wicket/models/TicGitTicket.java b/src/com/gitblit/wicket/models/TicketModel.java similarity index 84% rename from src/com/gitblit/wicket/models/TicGitTicket.java rename to src/com/gitblit/wicket/models/TicketModel.java index 6bbb7be0..39f3c902 100644 --- a/src/com/gitblit/wicket/models/TicGitTicket.java +++ b/src/com/gitblit/wicket/models/TicketModel.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -public class TicGitTicket implements Serializable, Comparable { +public class TicketModel implements Serializable, Comparable { private static final long serialVersionUID = 1L; @@ -22,13 +22,13 @@ public class TicGitTicket implements Serializable, Comparable { public List comments; public List tags; - public TicGitTicket() { + public TicketModel() { state = "open"; comments = new ArrayList(); tags = new ArrayList(); } - public TicGitTicket(String ticketName) throws ParseException { + public TicketModel(String ticketName) throws ParseException { state = ""; name = ticketName; comments = new ArrayList(); @@ -68,7 +68,7 @@ public class TicGitTicket implements Serializable, Comparable { } @Override - public int compareTo(TicGitTicket o) { + public int compareTo(TicketModel o) { return date.compareTo(o.date); } } diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.html b/src/com/gitblit/wicket/pages/TicketPage.html similarity index 100% rename from src/com/gitblit/wicket/pages/TicGitTicketPage.html rename to src/com/gitblit/wicket/pages/TicketPage.html diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.java b/src/com/gitblit/wicket/pages/TicketPage.java similarity index 86% rename from src/com/gitblit/wicket/pages/TicGitTicketPage.java rename to src/com/gitblit/wicket/pages/TicketPage.java index b4c9cf55..1cfa8090 100644 --- a/src/com/gitblit/wicket/pages/TicGitTicketPage.java +++ b/src/com/gitblit/wicket/pages/TicketPage.java @@ -12,18 +12,18 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.models.TicGitTicket; -import com.gitblit.wicket.models.TicGitTicket.Comment; +import com.gitblit.wicket.models.TicketModel; +import com.gitblit.wicket.models.TicketModel.Comment; -public class TicGitTicketPage extends RepositoryPage { +public class TicketPage extends RepositoryPage { - public TicGitTicketPage(PageParameters params) { + public TicketPage(PageParameters params) { super(params); final String ticketFolder = WicketUtils.getPath(params); Repository r = getRepository(); - TicGitTicket t = JGitUtils.getTicGitTicket(r, ticketFolder); + TicketModel t = JGitUtils.getTicket(r, ticketFolder); add(new Label("ticketTitle", t.title)); add(new Label("ticketId", t.id)); diff --git a/src/com/gitblit/wicket/pages/TicGitPage.html b/src/com/gitblit/wicket/pages/TicketsPage.html similarity index 100% rename from src/com/gitblit/wicket/pages/TicGitPage.html rename to src/com/gitblit/wicket/pages/TicketsPage.html diff --git a/src/com/gitblit/wicket/pages/TicGitPage.java b/src/com/gitblit/wicket/pages/TicketsPage.java similarity index 66% rename from src/com/gitblit/wicket/pages/TicGitPage.java rename to src/com/gitblit/wicket/pages/TicketsPage.java index a03ee607..865b8bf8 100644 --- a/src/com/gitblit/wicket/pages/TicGitPage.java +++ b/src/com/gitblit/wicket/pages/TicketsPage.java @@ -14,31 +14,31 @@ import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils; -import com.gitblit.wicket.models.TicGitTicket; +import com.gitblit.wicket.models.TicketModel; -public class TicGitPage extends RepositoryPage { +public class TicketsPage extends RepositoryPage { - public TicGitPage(PageParameters params) { + public TicketsPage(PageParameters params) { super(params); - List tickets = JGitUtils.getTicGitTickets(getRepository()); + List tickets = JGitUtils.getTickets(getRepository()); // header add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, newRepositoryParameter())); - ListDataProvider ticketsDp = new ListDataProvider(tickets); - DataView ticketsView = new DataView("ticket", ticketsDp) { + ListDataProvider ticketsDp = new ListDataProvider(tickets); + DataView ticketsView = new DataView("ticket", ticketsDp) { private static final long serialVersionUID = 1L; int counter = 0; - public void populateItem(final Item item) { - final TicGitTicket entry = item.getModelObject(); + public void populateItem(final Item item) { + final TicketModel entry = item.getModelObject(); Label stateLabel = new Label("ticketState", entry.state); WicketUtils.setTicketCssClass(stateLabel, entry.state); item.add(stateLabel); item.add(WicketUtils.createDateLabel("ticketDate", entry.date, GitBlitWebSession.get().getTimezone())); item.add(new Label("ticketHandler", StringUtils.trimString(entry.handler.toLowerCase(), 30))); - item.add(new LinkPanel("ticketTitle", "list subject", StringUtils.trimString(entry.title, 80), TicGitTicketPage.class, newPathParameter(entry.name))); + item.add(new LinkPanel("ticketTitle", "list subject", StringUtils.trimString(entry.title, 80), TicketPage.class, newPathParameter(entry.name))); WicketUtils.setAlternatingBackground(item, counter); counter++; @@ -49,6 +49,6 @@ public class TicGitPage extends RepositoryPage { @Override protected String getPageName() { - return getString("gb.ticgit"); + return getString("gb.tickets"); } } diff --git a/src/com/gitblit/wicket/panels/HistoryPanel.java b/src/com/gitblit/wicket/panels/HistoryPanel.java index 236e077b..e7878838 100644 --- a/src/com/gitblit/wicket/panels/HistoryPanel.java +++ b/src/com/gitblit/wicket/panels/HistoryPanel.java @@ -93,6 +93,7 @@ public class HistoryPanel extends BasePanel { item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs)); + // TODO links for folder item.add(new BookmarkablePageLink("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); item.add(new BookmarkablePageLink("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()))); item.add(new BookmarkablePageLink("difftocurrent", BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)).setEnabled(counter > 0)); diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.java b/src/com/gitblit/wicket/panels/PageLinksPanel.java index 18cfad62..f8824db5 100644 --- a/src/com/gitblit/wicket/panels/PageLinksPanel.java +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.java @@ -24,7 +24,7 @@ import com.gitblit.wicket.pages.BranchesPage; import com.gitblit.wicket.pages.LogPage; import com.gitblit.wicket.pages.SummaryPage; import com.gitblit.wicket.pages.TagsPage; -import com.gitblit.wicket.pages.TicGitPage; +import com.gitblit.wicket.pages.TicketsPage; import com.gitblit.wicket.pages.TreePage; public class PageLinksPanel extends Panel { @@ -41,7 +41,7 @@ public class PageLinksPanel extends Panel { put("branches", "gb.branches"); put("tags", "gb.tags"); put("tree", "gb.tree"); - put("ticgit", "gb.ticgit"); + put("tickets", "gb.tickets"); } }; @@ -55,14 +55,14 @@ public class PageLinksPanel extends Panel { add(new BookmarkablePageLink("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); add(new BookmarkablePageLink("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName))); - // Get the repository ticgit setting - boolean checkTicgit = GitBlit.self().settings().getBoolean(Keys.ticgit.global, false); - checkTicgit |= GitBlit.self().settings().getBoolean(MessageFormat.format(Keys.ticgit._ROOT + ".{0}", repositoryName), false); + // Get the repository tickets setting + boolean checkTicgit = GitBlit.self().settings().getBoolean(Keys.tickets.global, false); + checkTicgit |= GitBlit.self().settings().getBoolean(MessageFormat.format(Keys.tickets._ROOT + ".{0}", repositoryName), false); // Add dynamic repository extras List extras = new ArrayList(); - if (checkTicgit && JGitUtils.getTicGitBranch(r) != null) { - extras.add("ticgit"); + if (checkTicgit && JGitUtils.getTicketsBranch(r) != null) { + extras.add("tickets"); } ListDataProvider extrasDp = new ListDataProvider(extras); @@ -71,9 +71,9 @@ public class PageLinksPanel extends Panel { public void populateItem(final Item item) { String extra = item.getModelObject(); - if (extra.equals("ticgit")) { + if (extra.equals("tickets")) { item.add(new Label("extraSeparator", " | ")); - item.add(new LinkPanel("extraLink", null, "ticgit", TicGitPage.class, WicketUtils.newRepositoryParameter(repositoryName))); + item.add(new LinkPanel("extraLink", null, "tickets", TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); } } }; -- 2.39.5