James Moger
2011-04-17 9802a766a28bfcb0ae01494ebfa1cbeb11e71809
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.
5 files renamed
7 files modified
129 ■■■■ changed files
gitblit.properties 8 ●●●● patch | view | raw | blame | history
src/com/gitblit/tests/JGitUtilsTest.java 6 ●●●● patch | view | raw | blame | history
src/com/gitblit/utils/JGitUtils.java 46 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/GitBlitWebApp.java 10 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/GitBlitWebApp.properties 2 ●●● patch | view | raw | blame | history
src/com/gitblit/wicket/models/TicketModel.java 8 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/TicketPage.html patch | view | raw | blame | history
src/com/gitblit/wicket/pages/TicketPage.java 10 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/pages/TicketsPage.html patch | view | raw | blame | history
src/com/gitblit/wicket/pages/TicketsPage.java 20 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/HistoryPanel.java 1 ●●●● patch | view | raw | blame | history
src/com/gitblit/wicket/panels/PageLinksPanel.java 18 ●●●● patch | view | raw | blame | history
gitblit.properties
@@ -103,11 +103,11 @@
# Example per-repository regex substitutions overrides global
#regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://elsewhere/bug/$3">Bug-Id: $3</a>
# 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
src/com/gitblit/tests/JGitUtilsTest.java
@@ -17,7 +17,7 @@
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 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<TicGitTicket> tickets = JGitUtils.getTicGitTickets(r);
        List<TicketModel> tickets = JGitUtils.getTickets(r);
        assertTrue("No tickets found!", tickets.size() > 0);
        r.close();
    }
src/com/gitblit/utils/JGitUtils.java
@@ -46,8 +46,8 @@
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 @@
        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 @@
            // 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 @@
        return ticgitBranch;
    }
    public static List<TicGitTicket> getTicGitTickets(Repository r) {
        RefModel ticgitBranch = getTicGitBranch(r);
    public static List<TicketModel> getTickets(Repository r) {
        RefModel ticgitBranch = getTicketsBranch(r);
        List<PathModel> paths = getFilesInPath(r, null, ticgitBranch.getCommit());
        List<TicGitTicket> tickets = new ArrayList<TicGitTicket>();
        List<TicketModel> tickets = new ArrayList<TicketModel>();
        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 @@
        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<PathModel> ticketFiles = getFilesInPath(r, ticket.name, ticgitBranch.getCommit());
    private static void readTicketContents(Repository r, RefModel ticketsBranch, TicketModel ticket) {
        List<PathModel> 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 @@
        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 "";
    }
src/com/gitblit/wicket/GitBlitWebApp.java
@@ -25,8 +25,8 @@
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 @@
        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) {
src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -34,7 +34,7 @@
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
src/com/gitblit/wicket/models/TicketModel.java
File was renamed from src/com/gitblit/wicket/models/TicGitTicket.java
@@ -6,7 +6,7 @@
import java.util.Date;
import java.util.List;
public class TicGitTicket implements Serializable, Comparable<TicGitTicket> {
public class TicketModel implements Serializable, Comparable<TicketModel> {
    private static final long serialVersionUID = 1L;
@@ -22,13 +22,13 @@
    public List<Comment> comments;
    public List<String> tags;
    public TicGitTicket() {
    public TicketModel() {
        state = "open";
        comments = new ArrayList<Comment>();
        tags = new ArrayList<String>();
    }
    public TicGitTicket(String ticketName) throws ParseException {
    public TicketModel(String ticketName) throws ParseException {
        state = "";
        name = ticketName;
        comments = new ArrayList<Comment>();
@@ -68,7 +68,7 @@
    }
    @Override
    public int compareTo(TicGitTicket o) {
    public int compareTo(TicketModel o) {
        return date.compareTo(o.date);
    }
}
src/com/gitblit/wicket/pages/TicketPage.html
src/com/gitblit/wicket/pages/TicketPage.java
File was renamed from src/com/gitblit/wicket/pages/TicGitTicketPage.java
@@ -12,18 +12,18 @@
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));
src/com/gitblit/wicket/pages/TicketsPage.html
src/com/gitblit/wicket/pages/TicketsPage.java
File was renamed from src/com/gitblit/wicket/pages/TicGitPage.java
@@ -14,31 +14,31 @@
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<TicGitTicket> tickets = JGitUtils.getTicGitTickets(getRepository());
        List<TicketModel> tickets = JGitUtils.getTickets(getRepository());
        // header
        add(new LinkPanel("header", "title", repositoryName, SummaryPage.class, newRepositoryParameter()));
        ListDataProvider<TicGitTicket> ticketsDp = new ListDataProvider<TicGitTicket>(tickets);
        DataView<TicGitTicket> ticketsView = new DataView<TicGitTicket>("ticket", ticketsDp) {
        ListDataProvider<TicketModel> ticketsDp = new ListDataProvider<TicketModel>(tickets);
        DataView<TicketModel> ticketsView = new DataView<TicketModel>("ticket", ticketsDp) {
            private static final long serialVersionUID = 1L;
            int counter = 0;
            public void populateItem(final Item<TicGitTicket> item) {
                final TicGitTicket entry = item.getModelObject();
            public void populateItem(final Item<TicketModel> 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 @@
    @Override
    protected String getPageName() {
        return getString("gb.ticgit");
        return getString("gb.tickets");
    }
}
src/com/gitblit/wicket/panels/HistoryPanel.java
@@ -93,6 +93,7 @@
                item.add(new RefsPanel("commitRefs", repositoryName, entry, allRefs));
                // TODO links for folder
                item.add(new BookmarkablePageLink<Void>("view", CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));
                item.add(new BookmarkablePageLink<Void>("commitdiff", CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));
                item.add(new BookmarkablePageLink<Void>("difftocurrent", BlobDiffPage.class, WicketUtils.newPathParameter(repositoryName, entry.getName(), path)).setEnabled(counter > 0));
src/com/gitblit/wicket/panels/PageLinksPanel.java
@@ -24,7 +24,7 @@
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 @@
            put("branches", "gb.branches");
            put("tags", "gb.tags");
            put("tree", "gb.tree");
            put("ticgit", "gb.ticgit");
            put("tickets", "gb.tickets");
        }
    };
@@ -55,14 +55,14 @@
        add(new BookmarkablePageLink<Void>("tags", TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
        add(new BookmarkablePageLink<Void>("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<String> extras = new ArrayList<String>();
        if (checkTicgit && JGitUtils.getTicGitBranch(r) != null) {
            extras.add("ticgit");
        if (checkTicgit && JGitUtils.getTicketsBranch(r) != null) {
            extras.add("tickets");
        }
        ListDataProvider<String> extrasDp = new ListDataProvider<String>(extras);
@@ -71,9 +71,9 @@
            public void populateItem(final Item<String> 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)));
                }
            }
        };