Documentation. Unit testing. Checkstyle. Findbugs.
1 files added
35 files modified
| | |
| | | - updated: MarkdownPapers 1.1.0
|
| | | - updated: Jetty 7.4.3
|
| | |
|
| | | issues & binaries @ [Google Code][googlecode]<br/>
|
| | | issues, binaries, and sources @ [Google Code][googlecode]<br/>
|
| | | sources @ [Github][gitbltsrc]
|
| | |
|
| | | ### License
|
| | |
| | | * doFilter does the actual work of preprocessing the request to ensure that
|
| | | * the user may proceed.
|
| | | *
|
| | | * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
| | | * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
|
| | | * javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
| | | */
|
| | | @Override
|
| | | public void doFilter(final ServletRequest request, final ServletResponse response,
|
| | |
| | |
|
| | | public static final String BORDER = "***********************************************************";
|
| | |
|
| | | /**
|
| | | * Enumeration representing the 4 access restriction levels.
|
| | | */
|
| | | public static enum AccessRestrictionType {
|
| | | NONE, PUSH, CLONE, VIEW;
|
| | |
|
| | |
| | | * protected by an AccessRestrictionFilter. It performs its own authorization
|
| | | * check, but it does not perform any authentication. The assumption is that
|
| | | * requests to this servlet are made via the web ui and not by direct url
|
| | | * access. Unauthorized requests fail with a standard 403 (FORBIDDEN) code.
|
| | | * access. Unauthorized requests fail with a standard 403 (FORBIDDEN) code.
|
| | | *
|
| | | * @author James Moger
|
| | | *
|
| | |
| | | package com.gitblit;
|
| | |
|
| | | /**
|
| | | * GitBlitException is a marginally useful class. :)
|
| | | * GitBlitException is a marginally useful class. :)
|
| | | *
|
| | | * @author James Moger
|
| | | *
|
| | | * |
| | | */
|
| | | public class GitBlitException extends Exception {
|
| | |
|
| | |
| | | }
|
| | | if (params.securePort < 1024 && !isWindows()) {
|
| | | logger.warn("Gitblit needs to run with ROOT permissions for ports < 1024!");
|
| | | } |
| | | }
|
| | | connectors.add(secureConnector);
|
| | | } else {
|
| | | logger.warn("Failed to find or load Keystore?");
|
| | |
| | | connector.setMaxIdleTime(30000);
|
| | | return connector;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Tests to see if the operating system is Windows.
|
| | | *
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * JCommander Parameters class for GitBlitServer.
|
| | | */
|
| | | @Parameters(separators = " ")
|
| | | private static class Params {
|
| | |
|
| | |
| | | }
|
| | | return defaultValue;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Returns the char value for the specified key. If the key does not exist
|
| | | * or the value for the key can not be interpreted as a char, the
|
| | |
| | | * Utility class to generate self-signed certificates.
|
| | | *
|
| | | * @author James Moger
|
| | | *
|
| | | * |
| | | */
|
| | | public class MakeCertificate {
|
| | |
|
| | |
| | | jc.usage();
|
| | | }
|
| | | File keystore = new File("keystore");
|
| | | generateSelfSignedCertificate(params.hostname, keystore, params.storePassword, params.subject);
|
| | | generateSelfSignedCertificate(params.hostname, keystore, params.storePassword,
|
| | | params.subject);
|
| | | }
|
| | |
|
| | | public static void generateSelfSignedCertificate(String hostname, File keystore,
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * JCommander Parameters class for MakeCertificate.
|
| | | */
|
| | | @Parameters(separators = " ")
|
| | | private static class Params {
|
| | |
|
| | |
| | | */
|
| | | public class Build {
|
| | |
|
| | | /**
|
| | | * BuildType enumeration representing compile-time or runtime. This is used
|
| | | * to download dependencies either for Gitblit GO runtime or for setting up
|
| | | * a development environment.
|
| | | */
|
| | | public static enum BuildType {
|
| | | RUNTIME, COMPILETIME;
|
| | | }
|
| | |
| | | System.out.print("] " + url);
|
| | | }
|
| | |
|
| | | /**
|
| | | * MavenObject represents a complete maven artifact (binary, sources, and
|
| | | * javadoc). MavenObjects can be downloaded and checksummed to confirm
|
| | | * authenticity.
|
| | | */
|
| | | private static class MavenObject {
|
| | |
|
| | | public static final MavenObject JCOMMANDER = new MavenObject("jCommander", "com/beust",
|
| | |
| | | */
|
| | | public class BuildSite {
|
| | |
|
| | | private final static String CASE_SENSITIVE = "CASE-SENSITIVE";
|
| | | private static final String CASE_SENSITIVE = "CASE-SENSITIVE";
|
| | |
|
| | | private final static String RESTART_REQUIRED = "RESTART REQUIRED";
|
| | | private static final String RESTART_REQUIRED = "RESTART REQUIRED";
|
| | |
|
| | | private final static String SINCE = "SINCE";
|
| | | private static final String SINCE = "SINCE";
|
| | |
|
| | | public static void main(String... args) {
|
| | | Params params = new Params();
|
| | |
| | | if (!params.skips.contains(documentName)) {
|
| | | String fileName = documentName + ".html";
|
| | | System.out.println(MessageFormat.format(" {0} => {1}", file.getName(),
|
| | | fileName)); |
| | | fileName));
|
| | | String rawContent = FileUtils.readContent(file, "\n");
|
| | | String markdownContent = rawContent;
|
| | | |
| | |
|
| | | Map<String, List<String>> nomarkdownMap = new HashMap<String, List<String>>();
|
| | |
|
| | | // extract sections marked as no-markdown
|
| | |
| | | if (endCode == 0) {
|
| | | strippedContent.append(markdownContent.substring(0, beginCode));
|
| | | } else {
|
| | | strippedContent.append(markdownContent.substring(endCode, beginCode));
|
| | | } |
| | | strippedContent.append(markdownContent
|
| | | .substring(endCode, beginCode));
|
| | | }
|
| | | strippedContent.append(nomarkdownKey);
|
| | | endCode = markdownContent.indexOf(endToken, beginCode);
|
| | | chunks.add(markdownContent.substring(beginCode, endCode));
|
| | |
| | |
|
| | | // get remainder of text
|
| | | if (endCode < markdownContent.length()) {
|
| | | strippedContent.append(markdownContent.substring(endCode, markdownContent.length()));
|
| | | strippedContent.append(markdownContent.substring(endCode,
|
| | | markdownContent.length()));
|
| | | }
|
| | | markdownContent = strippedContent.toString();
|
| | | nmd++; |
| | | nmd++;
|
| | | }
|
| | |
|
| | | // transform markdown to html
|
| | | String content = transformMarkdown(markdownContent.toString());
|
| | |
|
| | | // reinsert nomarkdown chunks
|
| | | for (Map.Entry<String, List<String>> nomarkdown: nomarkdownMap.entrySet()) {
|
| | | for (String chunk:nomarkdown.getValue()) {
|
| | | for (Map.Entry<String, List<String>> nomarkdown : nomarkdownMap.entrySet()) {
|
| | | for (String chunk : nomarkdown.getValue()) {
|
| | | content = content.replaceFirst(nomarkdown.getKey(), chunk);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | for (String token : params.substitutions) {
|
| | | String[] kv = token.split("=", 2);
|
| | | content = content.replace(kv[0], kv[1]);
|
| | | }
|
| | | for (String token:params.regex) {
|
| | | for (String token : params.regex) {
|
| | | String[] kv = token.split("!!!", 2);
|
| | | content = content.replaceAll(kv[0], kv[1]);
|
| | | }
|
| | |
| | | content = content.replace(kv[0], loadedContent);
|
| | | }
|
| | | for (String alias : params.loads) {
|
| | | String[] kv = alias.split("=" ,2);
|
| | | String[] kv = alias.split("=", 2);
|
| | | String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");
|
| | | loadedContent = StringUtils.escapeForHtml(loadedContent, false);
|
| | | loadedContent = StringUtils.breakLinesForHtml(loadedContent);
|
| | |
| | | for (String comment : setting.comments) {
|
| | | if (comment.contains(SINCE) || comment.contains(RESTART_REQUIRED)
|
| | | || comment.contains(CASE_SENSITIVE)) {
|
| | | sb.append(MessageFormat.format("<span style=\"color:#004000;\"># <i>{0}</i></span>", transformMarkdown(comment)));
|
| | | sb.append(MessageFormat.format(
|
| | | "<span style=\"color:#004000;\"># <i>{0}</i></span>",
|
| | | transformMarkdown(comment)));
|
| | | } else {
|
| | | sb.append(MessageFormat.format("<span style=\"color:#004000;\"># {0}</span>", transformMarkdown(comment)));
|
| | | sb.append(MessageFormat.format("<span style=\"color:#004000;\"># {0}</span>",
|
| | | transformMarkdown(comment)));
|
| | | }
|
| | | sb.append("<br/>\n");
|
| | | }
|
| | | if (!StringUtils.isEmpty(setting.name)) {
|
| | | sb.append(MessageFormat.format("<span style=\"color:#000080;\">{0}</span> = <span style=\"color:#800000;\">{1}</span>", setting.name, StringUtils.escapeForHtml(setting.value, false)));
|
| | | sb.append(MessageFormat
|
| | | .format("<span style=\"color:#000080;\">{0}</span> = <span style=\"color:#800000;\">{1}</span>",
|
| | | setting.name, StringUtils.escapeForHtml(setting.value, false)));
|
| | | }
|
| | | sb.append("<br/>\n");
|
| | | }
|
| | |
|
| | | return sb.toString();
|
| | | }
|
| | | |
| | |
|
| | | private static String transformMarkdown(String comment) throws ParseException {
|
| | | String md = MarkdownUtils.transformMarkdown(comment);
|
| | | if (md.startsWith("<p>")) {
|
| | |
| | | System.exit(0);
|
| | | }
|
| | |
|
| | | /**
|
| | | * Setting represents a setting with its comments from the properties file.
|
| | | */
|
| | | private static class Setting {
|
| | | final String name;
|
| | | final String value;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * JCommander Parameters class for BuildSite.
|
| | | */
|
| | | @Parameters(separators = " ")
|
| | | private static class Params {
|
| | |
|
| | |
| | | */
|
| | | public static void createImageThumbnail(String sourceFolder, String destinationFolder,
|
| | | int maxDimension) {
|
| | | if (maxDimension <= 0)
|
| | | if (maxDimension <= 0) {
|
| | | return;
|
| | | }
|
| | | File source = new File(sourceFolder);
|
| | | File destination = new File(destinationFolder);
|
| | | destination.mkdirs();
|
| | |
| | | }
|
| | | }
|
| | | } finally {
|
| | | if (in != null)
|
| | | if (in != null) {
|
| | | in.close();
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * JCommander Parameters class for BuildThumbnails.
|
| | | */
|
| | | @Parameters(separators = " ")
|
| | | private static class Params {
|
| | |
|
| | |
| | | return key.startsWith(Keys.server._ROOT);
|
| | | }
|
| | |
|
| | | /**
|
| | | * Setting represents a setting and its comments from the properties file.
|
| | | */
|
| | | private static class Setting {
|
| | | final String name;
|
| | | final String value;
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * JCommander Parameters class for BuildWebXml.
|
| | | */
|
| | | @Parameters(separators = " ")
|
| | | private static class Params {
|
| | |
|
| | |
| | |
|
| | | private static final Logger LOGGER = LoggerFactory.getLogger(DiffUtils.class);
|
| | |
|
| | | /**
|
| | | * Enumeration for the diff output types.
|
| | | */
|
| | | public static enum DiffOutputType {
|
| | | PLAIN, GITWEB, GITBLIT;
|
| | |
|
| | |
| | | }
|
| | | long length = 0;
|
| | | for (File file : directory.listFiles()) {
|
| | | if (file.isFile())
|
| | | if (file.isFile()) {
|
| | | length += file.length();
|
| | | else
|
| | | } else {
|
| | | length += folderSize(file);
|
| | | }
|
| | | }
|
| | | return length;
|
| | | }
|
| | |
| | | import com.gitblit.models.PathModel.PathChangeModel;
|
| | | import com.gitblit.models.RefModel;
|
| | |
|
| | | /**
|
| | | * Collection of static methods for retrieving information from a repository.
|
| | | * |
| | | * @author James Moger
|
| | | * |
| | | */
|
| | | public class JGitUtils {
|
| | |
|
| | | static final Logger LOGGER = LoggerFactory.getLogger(JGitUtils.class);
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * Enumeration of the search types.
|
| | | */
|
| | | public static enum SearchType {
|
| | | AUTHOR, COMMITTER, COMMIT;
|
| | |
|
| | |
| | | */
|
| | | public static String transformMarkdown(String markdown) throws java.text.ParseException {
|
| | | try {
|
| | | return transformMarkdown(new StringReader(markdown));
|
| | | StringReader reader = new StringReader(markdown);
|
| | | String html = transformMarkdown(reader);
|
| | | reader.close();
|
| | | return html;
|
| | | } catch (NullPointerException p) {
|
| | | throw new java.text.ParseException("Markdown string is null!", 0);
|
| | | }
|
| | |
| | | } catch (ParseException p) {
|
| | | throw new java.text.ParseException(p.getMessage(), 0);
|
| | | } finally {
|
| | | try {
|
| | | markdownReader.close();
|
| | | } catch (IOException e) {
|
| | | // IGNORE
|
| | | }
|
| | | try {
|
| | | writer.close();
|
| | | } catch (IOException e) {
|
| | |
| | | return patch.toString();
|
| | | }
|
| | |
|
| | | /**
|
| | | * Class that represents the number of insertions and deletions from a
|
| | | * chunk.
|
| | | */
|
| | | private static class PatchTouple {
|
| | | int insertions;
|
| | | int deletions;
|
| | |
| | | * @return the string representation of the duration OR the css class
|
| | | */
|
| | | private static String timeAgo(Date date, boolean css) {
|
| | | String ago = null;
|
| | | if (isToday(date) || isYesterday(date)) {
|
| | | int mins = minutesAgo(date, true);
|
| | | if (mins >= 120) {
|
| | |
| | | }
|
| | | int hours = hoursAgo(date, true);
|
| | | if (hours > 23) {
|
| | | ago = "yesterday";
|
| | | return "yesterday";
|
| | | } else {
|
| | | ago = hours + " hours ago";
|
| | | return hours + " hours ago";
|
| | | }
|
| | | } else {
|
| | | if (css) {
|
| | | return "age0";
|
| | | }
|
| | | ago = mins + " min" + (mins > 1 ? "s" : "") + " ago";
|
| | | }
|
| | | if (css) {
|
| | | return "age0";
|
| | | }
|
| | | return mins + " min" + (mins > 1 ? "s" : "") + " ago";
|
| | | } else {
|
| | | if (css) {
|
| | | return "age2";
|
| | |
| | | int days = daysAgo(date, true);
|
| | | if (days < 365) {
|
| | | if (days <= 30) {
|
| | | ago = days + " days ago";
|
| | | return days + " days ago";
|
| | | } else if (days <= 90) {
|
| | | int weeks = days / 7;
|
| | | if (weeks == 12) {
|
| | | ago = "3 months ago";
|
| | | return "3 months ago";
|
| | | } else {
|
| | | ago = weeks + " weeks ago";
|
| | | return weeks + " weeks ago";
|
| | | }
|
| | | } else if (days > 90) {
|
| | | int months = days / 30;
|
| | | int weeks = (days % 30) / 7;
|
| | | if (weeks >= 2) {
|
| | | months++;
|
| | | }
|
| | | ago = months + " months ago";
|
| | | }
|
| | | int months = days / 30;
|
| | | int weeks = (days % 30) / 7;
|
| | | if (weeks >= 2) {
|
| | | months++;
|
| | | }
|
| | | return months + " months ago";
|
| | | } else if (days == 365) {
|
| | | ago = "1 year ago";
|
| | | return "1 year ago";
|
| | | } else {
|
| | | int yr = days / 365;
|
| | | days = days % 365;
|
| | | int months = (yr * 12) + (days / 30);
|
| | | if (months > 23) {
|
| | | ago = yr + " years ago";
|
| | | return yr + " years ago";
|
| | | } else {
|
| | | ago = months + " months ago";
|
| | | return months + " months ago";
|
| | | }
|
| | | }
|
| | | }
|
| | | return ago;
|
| | | }
|
| | | }
|
| | |
| | | import org.apache.wicket.Session;
|
| | | import org.apache.wicket.markup.html.WebPage;
|
| | | import org.apache.wicket.protocol.http.WebApplication;
|
| | | import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | |
| | | package com.gitblit.wicket;
|
| | |
|
| | | import org.apache.wicket.Page;
|
| | | import org.apache.wicket.protocol.http.WicketURLDecoder;
|
| | | import org.apache.wicket.protocol.http.WicketURLEncoder;
|
| | | import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | |
| | | * Panel fragment for displaying login or logout/change_password links.
|
| | | *
|
| | | */
|
| | | class UserFragment extends Fragment {
|
| | | static class UserFragment extends Fragment {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | |
| | | add(new Label("username", GitBlitWebSession.get().getUser().toString() + ":"));
|
| | | add(new LinkPanel("loginLink", null, markupProvider.getString("gb.logout"),
|
| | | LogoutPage.class));
|
| | | // quick and dirty hack for showing a separator |
| | | // quick and dirty hack for showing a separator
|
| | | add(new Label("separator", "|"));
|
| | | add(new BookmarkablePageLink<Void>("changePasswordLink", ChangePasswordPage.class));
|
| | | } else {
|
| | |
| | | throw new RestartResponseException(getApplication().getHomePage());
|
| | | }
|
| | |
|
| | | if (!GitBlit.getBoolean(Keys.web.authenticateAdminPages, true) && !GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) {
|
| | | if (!GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)
|
| | | && !GitBlit.getBoolean(Keys.web.authenticateViewPages, false)) {
|
| | | // no authentication enabled
|
| | | throw new RestartResponseException(getApplication().getHomePage());
|
| | | }
|
| | |
| | | confirmPasswordField.setResetPassword(false);
|
| | | form.add(confirmPasswordField);
|
| | | form.add(new FeedbackPanel("feedback"));
|
| | | |
| | |
|
| | | form.add(new Button("save"));
|
| | | Button cancel = new Button("cancel"){ |
| | | Button cancel = new Button("cancel") {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onSubmit() {
|
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | | |
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | |
|
| | | add(form);
|
| | | }
|
| | | }
|
| | |
| | | form.add(usersPalette);
|
| | |
|
| | | form.add(new Button("save"));
|
| | | Button cancel = new Button("cancel"){ |
| | | Button cancel = new Button("cancel") {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onSubmit() {
|
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | | |
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | |
|
| | | add(form);
|
| | | }
|
| | |
|
| | |
| | | form.add(confirmPasswordField);
|
| | | form.add(new CheckBox("canAdmin"));
|
| | | form.add(repositories);
|
| | | |
| | |
|
| | | form.add(new Button("save"));
|
| | | Button cancel = new Button("cancel"){ |
| | | Button cancel = new Button("cancel") {
|
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | @Override
|
| | | public void onSubmit() {
|
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | | |
| | | setResponsePage(RepositoriesPage.class);
|
| | | }
|
| | | };
|
| | | cancel.setDefaultFormProcessing(false);
|
| | | form.add(cancel);
|
| | |
|
| | | add(form);
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | public LogoutPage() {
|
| | | GitBlitWebSession.get().invalidate();
|
| | | GitBlit.self().setCookie(((WebResponse) getResponse()), null);
|
| | | GitBlit.self().setCookie((WebResponse) getResponse(), null);
|
| | | setRedirect(true);
|
| | | setResponsePage(getApplication().getHomePage());
|
| | | }
|
| | |
| | | InputStream is = res.getResourceStream().getInputStream();
|
| | | InputStreamReader reader = new InputStreamReader(is);
|
| | | message = MarkdownUtils.transformMarkdown(reader);
|
| | | reader.close();
|
| | | } catch (Throwable t) {
|
| | | message = "Failed to read default welcome message!";
|
| | | error(message, t, false);
|
| | |
| | | add(new Label("repositoryDescription", getRepositoryModel().description));
|
| | | add(new Label("repositoryOwner", getRepositoryModel().owner));
|
| | |
|
| | | add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r, null),
|
| | | getTimeZone()));
|
| | | add(WicketUtils.createTimestampLabel("repositoryLastChange",
|
| | | JGitUtils.getLastChange(r, null), getTimeZone()));
|
| | | if (metricsTotal == null) {
|
| | | add(new Label("branchStats", ""));
|
| | | } else {
|
| | |
| | |
|
| | | String author = entry.getAuthorIdent().getName();
|
| | | LinkPanel authorLink = new LinkPanel("branchAuthor", "list", author,
|
| | | SearchPage.class, WicketUtils.newSearchParameter(model.name, entry.getName(),
|
| | | author, SearchType.AUTHOR));
|
| | | SearchPage.class, WicketUtils.newSearchParameter(model.name,
|
| | | entry.getName(), author, SearchType.AUTHOR));
|
| | | setPersonSearchTooltip(authorLink, author, SearchType.AUTHOR);
|
| | | item.add(authorLink);
|
| | | |
| | |
|
| | | // short message
|
| | | String shortMessage = entry.getShortMessage();
|
| | | String trimmedMessage = StringUtils.trimShortLog(shortMessage);
|
| | | LinkPanel shortlog = new LinkPanel("branchLog", "list subject",
|
| | | trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(
|
| | | model.name, entry.getName()));
|
| | | LinkPanel shortlog = new LinkPanel("branchLog", "list subject", trimmedMessage,
|
| | | CommitPage.class, WicketUtils.newObjectParameter(model.name,
|
| | | entry.getName()));
|
| | | if (!shortMessage.equals(trimmedMessage)) {
|
| | | WicketUtils.setHtmlTooltip(shortlog, shortMessage);
|
| | | }
|
| | | item.add(shortlog);
|
| | | |
| | |
|
| | | if (maxCount <= 0) {
|
| | | Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);
|
| | | fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
|
| | |
| | | Map<String, List<RepositoryModel>> groups = new HashMap<String, List<RepositoryModel>>();
|
| | | for (RepositoryModel model : models) {
|
| | | String rootPath = StringUtils.getRootPath(model.name);
|
| | | if (StringUtils.isEmpty(rootPath)) { |
| | | if (StringUtils.isEmpty(rootPath)) {
|
| | | // root repository
|
| | | rootRepositories.add(model); |
| | | rootRepositories.add(model);
|
| | | } else {
|
| | | // non-root, grouped repository
|
| | | if (!groups.containsKey(rootPath)) {
|
| | |
| | | }
|
| | | List<String> roots = new ArrayList<String>(groups.keySet());
|
| | | Collections.sort(roots);
|
| | | |
| | |
|
| | | if (rootRepositories.size() > 0) {
|
| | | // inject the root repositories at the top of the page
|
| | | String rootPath = GitBlit.getString(Keys.web.repositoryRootGroupName, " ");
|
| | |
| | | row.add(new LinkPanel("repositoryDescription", "list", entry.description,
|
| | | SummaryPage.class, pp));
|
| | | if (showSize) {
|
| | | row.add(new Label("repositorySize", byteFormat.format(GitBlit.self().calculateSize(entry))));
|
| | | row.add(new Label("repositorySize", byteFormat.format(GitBlit.self()
|
| | | .calculateSize(entry))));
|
| | | } else {
|
| | | row.add(new Label("repositorySize").setVisible(false));
|
| | | }
|
| | |
| | | // New repository
|
| | | row.add(new Label("repositoryName", entry.name));
|
| | | row.add(new Label("repositoryDescription", entry.description));
|
| | | row.add(new Label("repositorySize", "<span class='empty'>(empty)</span>").setEscapeModelStrings(false));
|
| | | row.add(new Label("repositorySize", "<span class='empty'>(empty)</span>")
|
| | | .setEscapeModelStrings(false));
|
| | | }
|
| | |
|
| | | if (entry.useTickets) {
|
| | |
| | | item.add(new LinkPanel("tagName", "list name", entry.displayName, linkClass,
|
| | | WicketUtils.newObjectParameter(repositoryName, entry
|
| | | .getReferencedObjectId().getName())));
|
| | | |
| | |
|
| | | // workaround for RevTag returning a lengthy shortlog. :(
|
| | | String message = StringUtils.trimShortLog(entry.getShortMessage());
|
| | |
|
New file |
| | |
| | | /*
|
| | | * Copyright 2011 gitblit.com.
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package com.gitblit.tests;
|
| | |
|
| | | import java.io.File;
|
| | |
|
| | | import com.gitblit.utils.FileUtils;
|
| | |
|
| | | import junit.framework.TestCase;
|
| | |
|
| | | public class FileUtilsTest extends TestCase {
|
| | |
|
| | | public void testReadContent() throws Exception {
|
| | | File dir = new File(System.getProperty("user.dir"));
|
| | | String rawContent = FileUtils.readContent(new File(dir, "LICENSE"), "\n");
|
| | | assertTrue(rawContent.trim().startsWith("Apache License"));
|
| | | }
|
| | |
|
| | | public void testFolderSize() throws Exception {
|
| | | assertEquals(-1, FileUtils.folderSize(null));
|
| | | assertEquals(-1, FileUtils.folderSize(new File(System.getProperty("user.dir"), "pretend")));
|
| | |
|
| | | File dir = new File(System.getProperty("user.dir"), "distrib");
|
| | | long size = FileUtils.folderSize(dir);
|
| | | assertTrue("size is actually " + size, size >= 470000L);
|
| | |
|
| | | File file = new File(System.getProperty("user.dir"), "LICENSE");
|
| | | size = FileUtils.folderSize(file);
|
| | | assertTrue("size is actually " + size, size == 11556L);
|
| | |
|
| | | }
|
| | | } |
| | |
| | | import org.eclipse.jgit.lib.Repository;
|
| | | import org.eclipse.jgit.storage.file.FileRepository;
|
| | |
|
| | | import com.gitblit.FileUserService;
|
| | | import com.gitblit.FileSettings;
|
| | | import com.gitblit.FileUserService;
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.GitBlitException;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | |
| | |
|
| | | public static Test suite() {
|
| | | TestSuite suite = new TestSuite();
|
| | | suite.addTestSuite(FileUtilsTest.class);
|
| | | suite.addTestSuite(TimeUtilsTest.class);
|
| | | suite.addTestSuite(StringUtilsTest.class);
|
| | | suite.addTestSuite(ByteFormatTest.class);
|
| | |
| | | assertTrue("Helloworld model is null!", model != null);
|
| | | assertTrue(model.toString().equals(
|
| | | GitBlitSuite.getHelloworldRepository().getDirectory().getName()));
|
| | | assertEquals("" + GitBlit.self().calculateSize(model), GitBlit.self().calculateSize(model),
|
| | | 22004L);
|
| | | }
|
| | |
|
| | | public void testUserModel() throws Exception {
|
| | |
| | | assertFalse("Admin can still access repository!", model.canAccessRepository(repository));
|
| | | model.addRepository(repository);
|
| | | assertTrue("Admin can't access repository!", model.canAccessRepository(repository));
|
| | | assertEquals(GitBlit.self().getRepositoryModel(model, "pretend"), null);
|
| | | assertNotNull(GitBlit.self().getRepositoryModel(model, repository));
|
| | | assertTrue(GitBlit.self().getRepositoryModels(model).size() > 0);
|
| | | }
|
| | |
|
| | | public void testAccessRestrictionTypes() throws Exception {
|
| | |
| | |
|
| | | public void testFileSettings() throws Exception {
|
| | | FileSettings settings = new FileSettings("distrib/gitblit.properties");
|
| | | assertTrue(settings.getBoolean("missing", true) == true);
|
| | | assertTrue(settings.getBoolean("missing", true));
|
| | | assertTrue(settings.getString("missing", "default").equals("default"));
|
| | | assertTrue(settings.getInteger("missing", 10) == 10);
|
| | | assertTrue(settings.getInteger("realm.realmFile", 5) == 5);
|
| | |
|
| | | assertTrue(settings.getBoolean("git.enableGitServlet", false) == true);
|
| | | assertTrue(settings.getBoolean("git.enableGitServlet", false));
|
| | | assertTrue(settings.getString("realm.userService", null).equals("users.properties"));
|
| | | assertTrue(settings.getInteger("realm.minPasswordLength", 0) == 5);
|
| | | List<String> mdExtensions = settings.getStrings("web.markdownExtensions");
|
| | |
| | | List<String> keys = settings.getAllKeys("server");
|
| | | assertTrue(keys.size() > 0);
|
| | | assertTrue(keys.contains("server.httpsPort"));
|
| | |
|
| | | assertTrue(settings.getChar("web.forwardSlashCharacter", ' ') == '/');
|
| | | }
|
| | |
|
| | | public void testGitblitSettings() throws Exception {
|
| | | // These are already tested by above test method.
|
| | | assertTrue(GitBlit.getBoolean("missing", true) == true);
|
| | | assertTrue(GitBlit.getBoolean("missing", true));
|
| | | assertTrue(GitBlit.getString("missing", "default").equals("default"));
|
| | | assertTrue(GitBlit.getInteger("missing", 10) == 10);
|
| | | assertTrue(GitBlit.getInteger("realm.userService", 5) == 5);
|
| | |
|
| | | assertTrue(GitBlit.getBoolean("git.enableGitServlet", false) == true);
|
| | | assertTrue(GitBlit.getBoolean("git.enableGitServlet", false));
|
| | | assertTrue(GitBlit.getString("realm.userService", null).equals("users.properties"));
|
| | | assertTrue(GitBlit.getInteger("realm.minPasswordLength", 0) == 5);
|
| | | List<String> mdExtensions = GitBlit.getStrings("web.markdownExtensions");
|
| | |
| | | List<String> keys = GitBlit.getAllKeys("server");
|
| | | assertTrue(keys.size() > 0);
|
| | | assertTrue(keys.contains("server.httpsPort"));
|
| | |
|
| | | assertTrue(GitBlit.getChar("web.forwardSlashCharacter", ' ') == '/');
|
| | | assertFalse(GitBlit.isDebugMode());
|
| | | }
|
| | |
|
| | | public void testAuthentication() throws Exception {
|
| | |
| | | public class MetricUtilsTest extends TestCase {
|
| | |
|
| | | public void testMetrics() throws Exception {
|
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | testMetrics(GitBlitSuite.getHelloworldRepository());
|
| | | testMetrics(GitBlitSuite.getBluezGnomeRepository());
|
| | | }
|
| | |
|
| | | private void testMetrics(Repository repository) throws Exception {
|
| | | List<Metric> metrics = MetricUtils.getDateMetrics(repository, null, true, null);
|
| | | repository.close();
|
| | | assertTrue("No date metrics found!", metrics.size() > 0);
|
| | |
| | | String output = "this<br/>is<br/>a<br/>test<br/><br/>of<br/><br/>line<br/><br/>breaking";
|
| | | assertTrue(StringUtils.breakLinesForHtml(input).equals(output));
|
| | | }
|
| | | |
| | |
|
| | | public void testEncodeUrl() throws Exception {
|
| | | String input = "test /";
|
| | | String output = "test%20%2F";
|
| | |
| | | assertTrue(StringUtils.escapeForHtml(input, false).equals(outputNoChange));
|
| | | assertTrue(StringUtils.escapeForHtml(input, true).equals(outputChange));
|
| | | }
|
| | | |
| | |
|
| | | public void testDecodeForHtml() throws Exception {
|
| | | String input = "& < > "";
|
| | | String output = "& < > \"";
|
| | |
| | | assertTrue(StringUtils.getSHA1("blob 16\000what is up, doc?").equals(
|
| | | "bd9dbf5aae1a3862dd1526723246b20206e5fc37"));
|
| | | }
|
| | | |
| | |
|
| | | public void testMD5() throws Exception {
|
| | | assertTrue(StringUtils.getMD5("blob 16\000what is up, doc?").equals(
|
| | | "77fb8d95331f0d557472f6776d3aedf6"));
|
| | |
| | | Repository repository = GitBlitSuite.getHelloworldRepository();
|
| | | List<RevCommit> commits = JGitUtils.getRevLog(repository, 1);
|
| | | ByteArrayOutputStream os = new ByteArrayOutputStream();
|
| | | SyndicationUtils.toRSS("http://localhost", "Title", "Description", "Repository", commits, os);
|
| | | SyndicationUtils.toRSS("http://localhost", "Title", "Description", "Repository", commits,
|
| | | os);
|
| | | String feed = os.toString();
|
| | | os.close();
|
| | | assertTrue(feed.length() > 100);
|