+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.utils;\r
-\r
-import java.text.ParseException;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-\r
-import org.eclipse.jgit.lib.Repository;\r
-import org.eclipse.jgit.revwalk.RevCommit;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-import com.gitblit.models.PathModel;\r
-import com.gitblit.models.RefModel;\r
-import com.gitblit.models.TicketModel;\r
-import com.gitblit.models.TicketModel.Comment;\r
-\r
-/**\r
- * Utility class for reading Ticgit issues.\r
- * \r
- * @author James Moger\r
- * \r
- */\r
-public class TicgitUtils {\r
-\r
- static final Logger LOGGER = LoggerFactory.getLogger(TicgitUtils.class);\r
-\r
- /**\r
- * Returns a RefModel for the Ticgit branch in the repository. If the branch\r
- * can not be found, null is returned.\r
- * \r
- * @param repository\r
- * @return a refmodel for the ticgit branch or null\r
- */\r
- public static RefModel getTicketsBranch(Repository repository) {\r
- return JGitUtils.getBranch(repository, "ticgit");\r
- }\r
-\r
- /**\r
- * Returns a list of all tickets in the ticgit branch of the repository.\r
- * \r
- * @param repository\r
- * @return list of tickets\r
- */\r
- public static List<TicketModel> getTickets(Repository repository) {\r
- RefModel ticgitBranch = getTicketsBranch(repository);\r
- if (ticgitBranch == null) {\r
- return null;\r
- }\r
- RevCommit commit = (RevCommit) ticgitBranch.referencedObject;\r
- List<PathModel> paths = JGitUtils.getFilesInPath(repository, null, commit);\r
- List<TicketModel> tickets = new ArrayList<TicketModel>();\r
- for (PathModel ticketFolder : paths) {\r
- if (ticketFolder.isTree()) {\r
- try {\r
- TicketModel t = new TicketModel(ticketFolder.name);\r
- loadTicketContents(repository, ticgitBranch, t);\r
- tickets.add(t);\r
- } catch (Throwable t) {\r
- LOGGER.error("Failed to get a ticket!", t);\r
- }\r
- }\r
- }\r
- Collections.sort(tickets);\r
- Collections.reverse(tickets);\r
- return tickets;\r
- }\r
-\r
- /**\r
- * Returns a TicketModel for the specified ticgit ticket. Returns null if\r
- * the ticket does not exist or some other error occurs.\r
- * \r
- * @param repository\r
- * @param ticketFolder\r
- * @return a ticket\r
- */\r
- public static TicketModel getTicket(Repository repository, String ticketFolder) {\r
- RefModel ticketsBranch = getTicketsBranch(repository);\r
- if (ticketsBranch != null) {\r
- try {\r
- TicketModel ticket = new TicketModel(ticketFolder);\r
- loadTicketContents(repository, ticketsBranch, ticket);\r
- return ticket;\r
- } catch (Throwable t) {\r
- LOGGER.error("Failed to get ticket " + ticketFolder, t);\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- * Loads the contents of the ticket.\r
- * \r
- * @param repository\r
- * @param ticketsBranch\r
- * @param ticket\r
- */\r
- private static void loadTicketContents(Repository repository, RefModel ticketsBranch,\r
- TicketModel ticket) {\r
- RevCommit commit = (RevCommit) ticketsBranch.referencedObject;\r
- List<PathModel> ticketFiles = JGitUtils.getFilesInPath(repository, ticket.name, commit);\r
- for (PathModel file : ticketFiles) {\r
- String content = JGitUtils.getStringContent(repository, commit.getTree(), file.path)\r
- .trim();\r
- if (file.name.equals("TICKET_ID")) {\r
- ticket.id = content;\r
- } else if (file.name.equals("TITLE")) {\r
- ticket.title = content;\r
- } else {\r
- String[] chunks = file.name.split("_");\r
- if (chunks[0].equals("ASSIGNED")) {\r
- ticket.handler = content;\r
- } else if (chunks[0].equals("COMMENT")) {\r
- try {\r
- Comment c = new Comment(file.name, content);\r
- ticket.comments.add(c);\r
- } catch (ParseException e) {\r
- LOGGER.error("Failed to parse ticket comment", e);\r
- }\r
- } else if (chunks[0].equals("TAG")) {\r
- if (content.startsWith("TAG_")) {\r
- ticket.tags.add(content.substring(4));\r
- } else {\r
- ticket.tags.add(content);\r
- }\r
- } else if (chunks[0].equals("STATE")) {\r
- ticket.state = content;\r
- }\r
- }\r
- }\r
- Collections.sort(ticket.comments);\r
- }\r
-}\r
import com.gitblit.wicket.pages.SummaryPage;\r
import com.gitblit.wicket.pages.TagPage;\r
import com.gitblit.wicket.pages.TagsPage;\r
-import com.gitblit.wicket.pages.TicketPage;\r
-import com.gitblit.wicket.pages.TicketsPage;\r
import com.gitblit.wicket.pages.TreePage;\r
import com.gitblit.wicket.pages.UserPage;\r
import com.gitblit.wicket.pages.UsersPage;\r
public class GitBlitWebApp extends WebApplication {\r
\r
public final static Class<? extends BasePage> HOME_PAGE_CLASS = MyDashboardPage.class;\r
- \r
+\r
private final Map<String, CacheControl> cacheablePages = new HashMap<String, CacheControl>();\r
- \r
+\r
@Override\r
public void init() {\r
super.init();\r
mount("/users", UsersPage.class);\r
mount("/logout", LogoutPage.class);\r
\r
- // setup ticket urls\r
- mount("/tickets", TicketsPage.class, "r");\r
- mount("/ticket", TicketPage.class, "r", "f");\r
-\r
// setup the markdown urls\r
mount("/docs", DocsPage.class, "r");\r
mount("/markdown", MarkdownPage.class, "r", "h", "f");\r
parameters = new String[] {};\r
}\r
mount(new GitblitParamUrlCodingStrategy(location, clazz, parameters));\r
- \r
- // map the mount point to the cache control definition \r
+\r
+ // map the mount point to the cache control definition\r
if (clazz.isAnnotationPresent(CacheControl.class)) {\r
CacheControl cacheControl = clazz.getAnnotation(CacheControl.class);\r
cacheablePages.put(location.substring(1), cacheControl);\r
public Class<? extends Page> getHomePage() {\r
return HOME_PAGE_CLASS;\r
}\r
- \r
+\r
public boolean isCacheablePage(String mountPoint) {\r
return cacheablePages.containsKey(mountPoint);\r
}\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.RefLogUtils;\r
import com.gitblit.utils.StringUtils;\r
-import com.gitblit.utils.TicgitUtils;\r
import com.gitblit.wicket.CacheControl;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.PageRegistration;\r
import com.gitblit.wicket.panels.RefsPanel;\r
\r
public abstract class RepositoryPage extends RootPage {\r
- \r
+\r
private final Logger logger = LoggerFactory.getLogger(getClass());\r
\r
private final String PARAM_STAR = "star";\r
- \r
+\r
protected final String projectName;\r
protected final String repositoryName;\r
protected final String objectId;\r
- \r
+\r
private transient Repository r;\r
\r
private RepositoryModel m;\r
\r
private Map<String, SubmoduleModel> submodules;\r
- \r
+\r
private final Map<String, PageRegistration> registeredPages;\r
private boolean showAdmin;\r
private boolean isOwner;\r
- \r
+\r
public RepositoryPage(PageParameters params) {\r
super(params);\r
repositoryName = WicketUtils.getRepositoryName(params);\r
projectName = root;\r
}\r
objectId = WicketUtils.getObject(params);\r
- \r
+\r
if (StringUtils.isEmpty(repositoryName)) {\r
error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true);\r
}\r
if (!getRepositoryModel().hasCommits) {\r
setResponsePage(EmptyRepositoryPage.class, params);\r
}\r
- \r
+\r
if (getRepositoryModel().isCollectingGarbage) {\r
error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);\r
}\r
- \r
+\r
if (objectId != null) {\r
RefModel branch = null;\r
if ((branch = JGitUtils.getBranch(getRepository(), objectId)) != null) {\r
}\r
}\r
}\r
- \r
+\r
if (params.containsKey(PARAM_STAR)) {\r
// set starred state\r
boolean star = params.getBoolean(PARAM_STAR);\r
// set stateless page preference\r
setStatelessHint(true);\r
}\r
- \r
+\r
@Override\r
protected Class<? extends BasePage> getRootNavPageClass() {\r
return RepositoriesPage.class;\r
protected Class<? extends BasePage> getRepoNavPageClass() {\r
return getClass();\r
}\r
- \r
+\r
private Map<String, PageRegistration> registerPages() {\r
PageParameters params = null;\r
if (!StringUtils.isEmpty(repositoryName)) {\r
pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params));\r
// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params));\r
pages.put("reflog", new PageRegistration("gb.reflog", ReflogPage.class, params));\r
- } \r
+ }\r
pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params));\r
pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params));\r
pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true));\r
\r
// conditional links\r
// per-repository extra page links\r
- if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) {\r
- pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, params, true));\r
- }\r
if (model.showReadme || model.useDocs) {\r
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));\r
}\r
.getUsername()));\r
return pages;\r
}\r
- \r
+\r
protected boolean allowForkControls() {\r
return GitBlit.getBoolean(Keys.web.allowForking, true);\r
}\r
add(new LinkPanel("projectTitle", null, project.name,\r
ProjectPage.class, WicketUtils.newProjectParameter(project.name)));\r
}\r
- \r
+\r
String name = StringUtils.stripDotGit(repositoryName);\r
if (!StringUtils.isEmpty(projectName) && name.startsWith(projectName)) {\r
name = name.substring(projectName.length() + 1);\r
add(new LinkPanel("repositoryName", null, name, SummaryPage.class,\r
WicketUtils.newRepositoryParameter(repositoryName)));\r
add(new Label("pageName", pageName).setRenderBodyOnly(true));\r
- \r
+\r
UserModel user = GitBlitWebSession.get().getUser();\r
if (user == null) {\r
user = UserModel.ANONYMOUS;\r
} else {\r
// link to origin repository\r
Fragment forkFrag = new Fragment("originRepository", "originFragment", this);\r
- forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository), \r
+ forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository),\r
SummaryPage.class, WicketUtils.newRepositoryParameter(model.originRepository)));\r
add(forkFrag);\r
}\r
}\r
- \r
+\r
// (un)star link allows a user to star a repository\r
if (user.isAuthenticated) {\r
PageParameters starParams = DeepCopier.copy(getPageParameters());\r
if (hasFork || !canFork) {\r
// user not allowed to fork or fork already exists or repo forbids forking\r
add(new ExternalLink("forkLink", "").setVisible(false));\r
- \r
+\r
if (hasFork && !fork.equals(model.name)) {\r
// user has fork, view my fork link\r
String url = getRequestCycle().urlFor(SummaryPage.class, WicketUtils.newRepositoryParameter(fork)).toString();\r
add(new ExternalLink("forkLink", url));\r
}\r
}\r
- \r
+\r
if (showAdmin || isOwner) {\r
String url = getRequestCycle().urlFor(EditRepositoryPage.class, WicketUtils.newRepositoryParameter(model.name)).toString();\r
- add(new ExternalLink("editLink", url)); \r
+ add(new ExternalLink("editLink", url));\r
} else {\r
add(new Label("editLink").setVisible(false));\r
}\r
- \r
+\r
super.setupPage(repositoryName, pageName);\r
}\r
- \r
+\r
protected void addToolbarButton(String wicketId, String iconClass, String label, String url) {\r
Fragment button = new Fragment(wicketId, "toolbarLinkFragment", this);\r
Label icon = new Label("icon");\r
getSubmodules(commit);\r
return commit;\r
}\r
- \r
- protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) { \r
+\r
+ protected Map<String, SubmoduleModel> getSubmodules(RevCommit commit) {\r
if (submodules == null) {\r
submodules = new HashMap<String, SubmoduleModel>();\r
for (SubmoduleModel model : JGitUtils.getSubmodules(r, commit.getTree())) {\r
}\r
return submodules;\r
}\r
- \r
+\r
protected SubmoduleModel getSubmodule(String path) {\r
SubmoduleModel model = null;\r
if (submodules != null) {\r
// extract the repository name from the clone url\r
List<String> patterns = GitBlit.getStrings(Keys.git.submoduleUrlPatterns);\r
String submoduleName = StringUtils.extractRepositoryPath(model.url, patterns.toArray(new String[0]));\r
- \r
+\r
// determine the current path for constructing paths relative\r
// to the current repository\r
String currentPath = "";\r
return model;\r
}\r
}\r
- \r
+\r
// we do not have a copy of the submodule, but we need a path\r
model.gitblitPath = candidates.get(0);\r
return model;\r
- } \r
+ }\r
}\r
\r
protected String getShortObjectId(String objectId) {\r
setupPage(repositoryName, "/ " + getPageName());\r
super.onBeforeRender();\r
}\r
- \r
+\r
@Override\r
protected void setLastModified() {\r
if (getClass().isAnnotationPresent(CacheControl.class)) {\r
public boolean isShowAdmin() {\r
return showAdmin;\r
}\r
- \r
+\r
public boolean isOwner() {\r
return isOwner;\r
}\r
- \r
+\r
private class SearchForm extends SessionlessForm<Void> implements Serializable {\r
private static final long serialVersionUID = 1L;\r
\r
Constants.SearchType searchType = searchTypeModel.getObject();\r
String searchString = searchBoxModel.getObject();\r
if (StringUtils.isEmpty(searchString)) {\r
- // redirect to self to avoid wicket page update bug \r
+ // redirect to self to avoid wicket page update bug\r
PageParameters params = RepositoryPage.this.getPageParameters();\r
String relativeUrl = urlFor(RepositoryPage.this.getClass(), params).toString();\r
String absoluteUrl = RequestUtils.toAbsolutePath(relativeUrl);\r
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml" \r
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" \r
- xml:lang="en" \r
- lang="en"> \r
-\r
-<body>\r
-<wicket:extend>\r
-\r
- <!-- ticket title -->\r
- <div style="font-size:150%;padding-top:5px;padding-bottom:5px;" wicket:id="ticketTitle">[ticket title]</div>\r
- \r
- <!-- ticket info -->\r
- <table class="plain">\r
- <tr><th><wicket:message key="gb.ticketId">ticket id</wicket:message></th><td><span class="sha1" wicket:id="ticketId">[ticket id]</span></td></tr>\r
- <tr><th><wicket:message key="gb.ticketAssigned">assigned</wicket:message></th><td><span wicket:id=ticketHandler>[ticket title]</span></td></tr>\r
- <tr><th><wicket:message key="gb.ticketOpenDate">open date</wicket:message></th><td><span wicket:id="ticketOpenDate">[ticket open date]</span></td></tr>\r
- <tr><th><wicket:message key="gb.ticketState">state</wicket:message></th><td><span wicket:id="ticketState">[ticket state]</span></td></tr>\r
- <tr><th><wicket:message key="gb.tags">tags</wicket:message></th><td><span wicket:id="ticketTags">[ticket tags]</span></td></tr>\r
- </table>\r
- \r
- <!-- comments header -->\r
- <div class="header"><wicket:message key="gb.ticketComments">comments</wicket:message></div>\r
- \r
- <!-- comments -->\r
- <table class="comments">\r
- <tbody>\r
- <tr valign="top" wicket:id="comment">\r
- <td><span class="author" wicket:id="commentAuthor">[comment author]</span><br/>\r
- <span class="date" wicket:id="commentDate">[comment date]</span>\r
- </td>\r
- <td><span wicket:id="commentText">[comment text]</span></td>\r
- </tr>\r
- </tbody>\r
- </table>\r
-\r
-</wicket:extend> \r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket.pages;\r
-\r
-import org.apache.wicket.PageParameters;\r
-import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.markup.repeater.Item;\r
-import org.apache.wicket.markup.repeater.data.DataView;\r
-import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
-import org.eclipse.jgit.lib.Repository;\r
-\r
-import com.gitblit.models.TicketModel;\r
-import com.gitblit.models.TicketModel.Comment;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.utils.TicgitUtils;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
-import com.gitblit.wicket.WicketUtils;\r
-\r
-public class TicketPage extends RepositoryPage {\r
-\r
- public TicketPage(PageParameters params) {\r
- super(params);\r
-\r
- final String ticketFolder = WicketUtils.getPath(params);\r
-\r
- Repository r = getRepository();\r
- TicketModel t = TicgitUtils.getTicket(r, ticketFolder);\r
-\r
- add(new Label("ticketTitle", t.title));\r
- add(new Label("ticketId", t.id));\r
- add(new Label("ticketHandler", t.handler.toLowerCase()));\r
- add(WicketUtils.createTimestampLabel("ticketOpenDate", t.date, getTimeZone(), getTimeUtils()));\r
- Label stateLabel = new Label("ticketState", t.state);\r
- WicketUtils.setTicketCssClass(stateLabel, t.state);\r
- add(stateLabel);\r
- add(new Label("ticketTags", StringUtils.flattenStrings(t.tags)));\r
-\r
- ListDataProvider<Comment> commentsDp = new ListDataProvider<Comment>(t.comments);\r
- DataView<Comment> commentsView = new DataView<Comment>("comment", commentsDp) {\r
- private static final long serialVersionUID = 1L;\r
- int counter;\r
-\r
- public void populateItem(final Item<Comment> item) {\r
- final Comment entry = item.getModelObject();\r
- item.add(WicketUtils.createDateLabel("commentDate", entry.date, GitBlitWebSession\r
- .get().getTimezone(), getTimeUtils()));\r
- item.add(new Label("commentAuthor", entry.author.toLowerCase()));\r
- item.add(new Label("commentText", prepareComment(entry.text))\r
- .setEscapeModelStrings(false));\r
- WicketUtils.setAlternatingBackground(item, counter);\r
- counter++;\r
- }\r
- };\r
- add(commentsView);\r
- }\r
-\r
- @Override\r
- protected String getPageName() {\r
- return getString("gb.ticket");\r
- }\r
- \r
- @Override\r
- protected Class<? extends BasePage> getRepoNavPageClass() {\r
- return TicketsPage.class;\r
- }\r
-\r
- private String prepareComment(String comment) {\r
- String html = StringUtils.escapeForHtml(comment, false);\r
- html = StringUtils.breakLinesForHtml(comment).trim();\r
- return html.replaceAll("\\bcommit\\s*([A-Za-z0-9]*)\\b", "<a href=\"/commit/"\r
- + repositoryName + "/$1\">commit $1</a>");\r
- }\r
-}\r
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
-<html xmlns="http://www.w3.org/1999/xhtml" \r
- xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" \r
- xml:lang="en" \r
- lang="en"> \r
-\r
-<body>\r
-<wicket:extend>\r
-\r
- <!-- tickets --> \r
- <table class="pretty">\r
- <tbody>\r
- <tr wicket:id="ticket">\r
- <td style="padding:0; margin:0;"><div wicket:id="ticketState">[ticket state]</div></td>\r
- <td class="date"><span wicket:id="ticketDate">[ticket date]</span></td>\r
- <td class="author"><div wicket:id="ticketHandler">[ticket handler]</div></td>\r
- <td><div wicket:id="ticketTitle">[ticket title]</div></td>\r
- </tr>\r
- </tbody>\r
- </table> \r
-\r
-</wicket:extend>\r
-</body>\r
-</html>
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.wicket.pages;\r
-\r
-import java.util.List;\r
-\r
-import org.apache.wicket.PageParameters;\r
-import org.apache.wicket.markup.html.basic.Label;\r
-import org.apache.wicket.markup.repeater.Item;\r
-import org.apache.wicket.markup.repeater.data.DataView;\r
-import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
-\r
-import com.gitblit.models.TicketModel;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.utils.TicgitUtils;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
-import com.gitblit.wicket.WicketUtils;\r
-import com.gitblit.wicket.panels.LinkPanel;\r
-\r
-public class TicketsPage extends RepositoryPage {\r
-\r
- public TicketsPage(PageParameters params) {\r
- super(params);\r
-\r
- List<TicketModel> tickets = TicgitUtils.getTickets(getRepository());\r
-\r
- ListDataProvider<TicketModel> ticketsDp = new ListDataProvider<TicketModel>(tickets);\r
- DataView<TicketModel> ticketsView = new DataView<TicketModel>("ticket", ticketsDp) {\r
- private static final long serialVersionUID = 1L;\r
- int counter;\r
-\r
- public void populateItem(final Item<TicketModel> item) {\r
- final TicketModel entry = item.getModelObject();\r
- Label stateLabel = new Label("ticketState", entry.state);\r
- WicketUtils.setTicketCssClass(stateLabel, entry.state);\r
- item.add(stateLabel);\r
- item.add(WicketUtils.createDateLabel("ticketDate", entry.date, GitBlitWebSession\r
- .get().getTimezone(), getTimeUtils()));\r
- item.add(new Label("ticketHandler", StringUtils.trimString(\r
- entry.handler.toLowerCase(), 30)));\r
- item.add(new LinkPanel("ticketTitle", "list subject", StringUtils.trimString(\r
- entry.title, 80), TicketPage.class, newPathParameter(entry.name)));\r
-\r
- WicketUtils.setAlternatingBackground(item, counter);\r
- counter++;\r
- }\r
- };\r
- add(ticketsView);\r
- }\r
-\r
- protected PageParameters newPathParameter(String path) {\r
- return WicketUtils.newPathParameter(repositoryName, objectId, path);\r
- }\r
-\r
- @Override\r
- protected String getPageName() {\r
- return getString("gb.tickets");\r
- }\r
-}\r
<img class="inlineIcon" wicket:id="frozenIcon" />\r
<img class="inlineIcon" wicket:id="federatedIcon" />\r
\r
- <a style="text-decoration: none;" wicket:id="tickets" wicket:message="title:gb.tickets">\r
- <img style="border:0px;vertical-align:middle;" src="bug_16x16.png"></img>\r
- </a>\r
<a style="text-decoration: none;" wicket:id="docs" wicket:message="title:gb.docs">\r
<img style="border:0px;vertical-align:middle;" src="book_16x16.png"></img>\r
</a>\r
import com.gitblit.wicket.pages.EditRepositoryPage;\r
import com.gitblit.wicket.pages.LogPage;\r
import com.gitblit.wicket.pages.SummaryPage;\r
-import com.gitblit.wicket.pages.TicketsPage;\r
import com.gitblit.wicket.pages.TreePage;\r
\r
public class ProjectRepositoryPanel extends BasePanel {\r
add(new Label("originRepository").setVisible(false));\r
} else {\r
Fragment forkFrag = new Fragment("originRepository", "originFragment", this);\r
- forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(entry.originRepository), \r
+ forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(entry.originRepository),\r
SummaryPage.class, WicketUtils.newRepositoryParameter(entry.originRepository)));\r
add(forkFrag);\r
}\r
add(WicketUtils.newClearPixel("sparkleshareIcon").setVisible(false));\r
}\r
\r
- add(new BookmarkablePageLink<Void>("tickets", TicketsPage.class, pp).setVisible(entry.useTickets));\r
add(new BookmarkablePageLink<Void>("docs", DocsPage.class, pp).setVisible(entry.useDocs));\r
\r
if (entry.isFrozen) {\r
String owner = "";\r
for (String username : entry.owners) {\r
UserModel ownerModel = GitBlit.self().getUserModel(username);\r
- \r
+\r
if (ownerModel != null) {\r
owner = ownerModel.getDisplayName();\r
- } \r
+ }\r
}\r
if (entry.owners.size() > 1) {\r
owner += ", ...";\r
- Syntax highlighting for popular source code types\r
- Customizable regular expression substitution for commit messages (i.e. bug or code review link integration)\r
- Single text file for users configuration\r
-- Optional utility pages\r
- - ![docs](book_16x16.png) Docs page which enumerates all Markdown files within a repository\r
- - ![tickets](bug_16x16.png) **readonly and deprecated** Ticgit ticket pages *(based on last MIT release bf57b032 2009-01-27)*\r
+- Optional Docs page which enumerates all Markdown files within a repository\r
+2009-01-27)*\r
- Translations\r
- English\r
- Japanese\r
* The GitBlitSuite uses test-gitblit.properties and test-users.conf. The suite\r
* is fairly comprehensive for all lower-level functionality. Wicket pages are\r
* currently not unit-tested.\r
- * \r
+ *\r
* This suite starts a Gitblit server instance within the same JVM instance as\r
* the unit tests. This allows the unit tests to access the GitBlit static\r
* singleton while also being able to communicate with the instance via tcp/ip\r
* for testing rpc requests, federation requests, and git servlet operations.\r
- * \r
+ *\r
* @author James Moger\r
- * \r
+ *\r
*/\r
@RunWith(Suite.class)\r
@SuiteClasses({ ArrayUtilsTest.class, FileUtilsTest.class, TimeUtilsTest.class,\r
StringUtilsTest.class, Base64Test.class, JsonUtilsTest.class, ByteFormatTest.class,\r
ObjectCacheTest.class, PermissionsTest.class, UserServiceTest.class, LdapUserServiceTest.class,\r
MarkdownUtilsTest.class, JGitUtilsTest.class, SyndicationUtilsTest.class,\r
- DiffUtilsTest.class, MetricUtilsTest.class, TicgitUtilsTest.class, X509UtilsTest.class,\r
+ DiffUtilsTest.class, MetricUtilsTest.class, X509UtilsTest.class,\r
GitBlitTest.class, FederationTests.class, RpcTests.class, GitServletTest.class, GitDaemonTest.class,\r
GroovyScriptTest.class, LuceneExecutorTest.class, IssuesTest.class, RepositoryModelTest.class,\r
FanoutServiceTest.class, Issue0259Test.class, Issue0271Test.class, HtpasswdUserServiceTest.class,\r
public class GitBlitSuite {\r
\r
public static final File REPOSITORIES = new File("data/git");\r
- \r
+\r
public static final File SETTINGS = new File("src/test/config/test-gitblit.properties");\r
- \r
+\r
public static final File USERSCONF = new File("src/test/config/test-users.conf");\r
\r
static int port = 8280;\r
JGitUtils.createRepository(REPOSITORIES, "gb-issues.git").close();\r
return getRepository("gb-issues.git");\r
}\r
- \r
+\r
public static Repository getGitectiveRepository() throws Exception {\r
return getRepository("test/gitective.git");\r
}\r
- \r
+\r
private static Repository getRepository(String name) throws Exception {\r
File gitDir = FileKey.resolve(new File(REPOSITORIES, name), FS.DETECTED);\r
Repository repository = new FileRepositoryBuilder().setGitDir(gitDir).build();\r
// already started\r
return false;\r
}\r
- \r
+\r
GitServletTest.deleteWorkingFolders();\r
- \r
+\r
// Start a Gitblit instance\r
Executors.newSingleThreadExecutor().execute(new Runnable() {\r
+ @Override\r
public void run() {\r
GitBlitServer.main("--httpPort", "" + port, "--httpsPort", "0", "--shutdownPort",\r
"" + shutdownPort, "--gitPort", "" + gitPort, "--repositoriesFolder",\r
cloneOrFetch("test/helloworld.git", "https://github.com/git/hello-world.git");\r
cloneOrFetch("test/ambition.git", "https://github.com/defunkt/ambition.git");\r
cloneOrFetch("test/gitective.git", "https://github.com/kevinsawicki/gitective.git");\r
- \r
+\r
enableTickets("ticgit.git");\r
enableDocs("ticgit.git");\r
showRemoteBranches("ticgit.git");\r
automaticallyTagBranchTips("ticgit.git");\r
showRemoteBranches("test/jgit.git");\r
- automaticallyTagBranchTips("test/jgit.git"); \r
+ automaticallyTagBranchTips("test/jgit.git");\r
}\r
}\r
\r
g.printStackTrace();\r
}\r
}\r
- \r
+\r
private static void automaticallyTagBranchTips(String repositoryName) {\r
try {\r
RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
g.printStackTrace();\r
}\r
}\r
- \r
+\r
public static void close(File repository) {\r
try {\r
File gitDir = FileKey.resolve(repository, FS.detect());\r
e.printStackTrace();\r
}\r
}\r
- \r
+\r
public static void close(Git git) {\r
close(git.getRepository());\r
}\r
- \r
+\r
public static void close(Repository r) {\r
RepositoryCache.close(r);\r
\r
+++ /dev/null
-/*\r
- * Copyright 2011 gitblit.com.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package com.gitblit.tests;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-import static org.junit.Assert.assertFalse;\r
-import static org.junit.Assert.assertNotNull;\r
-import static org.junit.Assert.assertNull;\r
-import static org.junit.Assert.assertTrue;\r
-\r
-import java.util.List;\r
-\r
-import org.eclipse.jgit.lib.Repository;\r
-import org.junit.Test;\r
-\r
-import com.gitblit.models.RefModel;\r
-import com.gitblit.models.TicketModel;\r
-import com.gitblit.models.TicketModel.Comment;\r
-import com.gitblit.utils.TicgitUtils;\r
-\r
-public class TicgitUtilsTest {\r
-\r
- @Test\r
- public void testTicgitBranch() throws Exception {\r
- Repository repository = GitBlitSuite.getTicgitRepository();\r
- RefModel branch = TicgitUtils.getTicketsBranch(repository);\r
- repository.close();\r
- assertNotNull("Ticgit branch does not exist!", branch);\r
-\r
- repository = GitBlitSuite.getHelloworldRepository();\r
- branch = TicgitUtils.getTicketsBranch(repository);\r
- repository.close();\r
- assertNull("Ticgit branch exists!", branch);\r
- }\r
-\r
- @Test\r
- public void testRetrieveTickets() throws Exception {\r
- Repository repository = GitBlitSuite.getTicgitRepository();\r
- List<TicketModel> ticketsA = TicgitUtils.getTickets(repository);\r
- List<TicketModel> ticketsB = TicgitUtils.getTickets(repository);\r
- repository.close();\r
- assertTrue("No tickets found!", ticketsA.size() > 0);\r
- for (int i = 0; i < ticketsA.size(); i++) {\r
- TicketModel ticketA = ticketsA.get(i);\r
- TicketModel ticketB = ticketsB.get(i);\r
- assertTrue("Tickets are not equal!", ticketA.equals(ticketB));\r
- assertFalse(ticketA.equals(""));\r
- assertTrue(ticketA.hashCode() == ticketA.id.hashCode());\r
- for (int j = 0; j < ticketA.comments.size(); j++) {\r
- Comment commentA = ticketA.comments.get(j);\r
- Comment commentB = ticketB.comments.get(j);\r
- assertTrue("Comments are not equal!", commentA.equals(commentB));\r
- assertFalse(commentA.equals(""));\r
- assertEquals(commentA.hashCode(), commentA.text.hashCode());\r
- }\r
- }\r
-\r
- repository = GitBlitSuite.getHelloworldRepository();\r
- List<TicketModel> ticketsC = TicgitUtils.getTickets(repository);\r
- repository.close();\r
- assertNull(ticketsC);\r
- }\r
-\r
- @Test\r
- public void testReadTicket() throws Exception {\r
- Repository repository = GitBlitSuite.getTicgitRepository();\r
- List<TicketModel> tickets = TicgitUtils.getTickets(repository);\r
- TicketModel ticket = TicgitUtils\r
- .getTicket(repository, tickets.get(tickets.size() - 1).name);\r
- repository.close();\r
- assertNotNull(ticket);\r
- assertEquals("1206206148_add-attachment-to-ticket_138", ticket.name);\r
- }\r
-}
\ No newline at end of file