diff --git a/src/org/opensolaris/opengrok/configuration/Configuration.java b/src/org/opensolaris/opengrok/configuration/Configuration.java index 1dfe315229b..7d890bb6a84 100644 --- a/src/org/opensolaris/opengrok/configuration/Configuration.java +++ b/src/org/opensolaris/opengrok/configuration/Configuration.java @@ -169,6 +169,13 @@ public final class Configuration { */ private int revisionMessageCollapseThreshold; + /** + * Current indexed message will be collapsible if they exceed this many number of + * characters. Front end enforces an appropriate minimum. + */ + private int currentIndexedCollapseThreshold; + + /** * Upper bound for number of threads used for performing multi-project * searches. This is total for the whole webapp/CLI utility. @@ -287,6 +294,7 @@ public Configuration() { setMaxSearchThreadCount(2 * Runtime.getRuntime().availableProcessors()); setIndexRefreshPeriod(60); setMessageLimit(500); + setCurrentIndexedCollapseThreshold(27); } public String getRepoCmd(String clazzName) { @@ -709,6 +717,14 @@ public int getRevisionMessageCollapseThreshold() { return this.revisionMessageCollapseThreshold; } + public int getCurrentIndexedCollapseThreshold() { + return currentIndexedCollapseThreshold; + } + + public void setCurrentIndexedCollapseThreshold(int currentIndexedCollapseThreshold) { + this.currentIndexedCollapseThreshold = currentIndexedCollapseThreshold; + } + private transient Date lastModified; /** diff --git a/src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java b/src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java index fa303c55368..f8fcd75bc86 100644 --- a/src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java +++ b/src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java @@ -1088,6 +1088,14 @@ public int getMaxSearchThreadCount() { return threadConfig.get().getMaxSearchThreadCount(); } + public int getCurrentIndexedCollapseThreshold() { + return threadConfig.get().getCurrentIndexedCollapseThreshold(); + } + + public void setCurrentIndexedCollapseThreshold(int currentIndexedCollapseThreshold) { + threadConfig.get().getCurrentIndexedCollapseThreshold(); + } + /** * Read an configuration file and set it as the current configuration. * diff --git a/src/org/opensolaris/opengrok/history/GitRepository.java b/src/org/opensolaris/opengrok/history/GitRepository.java index 42382dae0dc..79f083c7a9c 100644 --- a/src/org/opensolaris/opengrok/history/GitRepository.java +++ b/src/org/opensolaris/opengrok/history/GitRepository.java @@ -662,4 +662,30 @@ String determineBranch() throws IOException { return branch; } + + @Override + String determineCurrentVersion() throws IOException { + String line = null; + File directory = new File(directoryName); + + List cmd = new ArrayList<>(); + ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK); + cmd.add(RepoCommand); + cmd.add("log"); + cmd.add("-1"); + cmd.add("--pretty=%cd: %h %an %s"); + cmd.add("--date=format:%Y-%m-%d %H:%M"); + ProcessBuilder pb = new ProcessBuilder(cmd); + pb.directory(directory); + Process process; + process = pb.start(); + + try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + if ((line = in.readLine()) != null) { + line = line.trim(); + } + } + + return line; + } } diff --git a/src/org/opensolaris/opengrok/history/Repository.java b/src/org/opensolaris/opengrok/history/Repository.java index 258de44220f..47f5706b18c 100644 --- a/src/org/opensolaris/opengrok/history/Repository.java +++ b/src/org/opensolaris/opengrok/history/Repository.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. */ package org.opensolaris.opengrok.history; @@ -364,6 +364,18 @@ final void createCache(HistoryCache cache, String sinceRevision) */ abstract String determineBranch() throws IOException; + /** + * Determine and return the current version of the repository. + * + * This operation is consider "heavy" so this function should not be + * called on every web request. + * + * @return the version + */ + String determineCurrentVersion() throws IOException { + return null; + } + /** * Returns true if this repository supports sub repositories (a.k.a. * forests). diff --git a/src/org/opensolaris/opengrok/history/RepositoryFactory.java b/src/org/opensolaris/opengrok/history/RepositoryFactory.java index 6a0ba756a69..a8b006c142f 100644 --- a/src/org/opensolaris/opengrok/history/RepositoryFactory.java +++ b/src/org/opensolaris/opengrok/history/RepositoryFactory.java @@ -134,6 +134,16 @@ public static Repository getRepository(File file) throws InstantiationException, } } + if (res.getCurrentVersion() == null || res.getCurrentVersion().length() == 0) { + try { + res.setCurrentVersion(res.determineCurrentVersion()); + } catch (IOException ex) { + LOGGER.log(Level.WARNING, + "Failed to determineCurrentVersion for {0}: {1}", + new Object[]{file.getAbsolutePath(), ex}); + } + } + // If this repository displays tags only for files changed by tagged // revision, we need to prepare list of all tags in advance. if (env.isTagsEnabled() && res.hasFileBasedTags()) { diff --git a/src/org/opensolaris/opengrok/history/RepositoryInfo.java b/src/org/opensolaris/opengrok/history/RepositoryInfo.java index 5070a67e924..62c8f488617 100644 --- a/src/org/opensolaris/opengrok/history/RepositoryInfo.java +++ b/src/org/opensolaris/opengrok/history/RepositoryInfo.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. */ package org.opensolaris.opengrok.history; @@ -42,6 +42,7 @@ public class RepositoryInfo implements Serializable { protected String datePattern; protected String parent; protected String branch; + protected String currentVersion; /** * Empty constructor to support serialization. @@ -58,6 +59,7 @@ public RepositoryInfo(RepositoryInfo orig) { this.datePattern = orig.datePattern; this.parent = orig.parent; this.branch = orig.branch; + this.currentVersion = orig.currentVersion; } /** @@ -167,4 +169,12 @@ public String getBranch() { public void setBranch(String branch) { this.branch = branch; } + + public String getCurrentVersion() { + return currentVersion; + } + + public void setCurrentVersion(String currentVersion) { + this.currentVersion = currentVersion; + } } diff --git a/src/org/opensolaris/opengrok/web/PageConfig.java b/src/org/opensolaris/opengrok/web/PageConfig.java index 5fc9b798c3d..d2fd03bbe0f 100644 --- a/src/org/opensolaris/opengrok/web/PageConfig.java +++ b/src/org/opensolaris/opengrok/web/PageConfig.java @@ -477,6 +477,10 @@ public int getRevisionMessageCollapseThreshold() { return getEnv().getRevisionMessageCollapseThreshold(); } + public int getCurrentIndexedCollapseThreshold() { + return getEnv().getCurrentIndexedCollapseThreshold(); + } + /** * Get sort orders from the request parameter {@code sort} and if this list * would be empty from the cookie {@code OpenGrokorting}. diff --git a/web/default/style.css b/web/default/style.css index 523ed967477..c31ab057344 100644 --- a/web/default/style.css +++ b/web/default/style.css @@ -215,6 +215,9 @@ label { margin-bottom: 0; } +.panel-body > table tr td:last-child, .panel-body-accordion > table tr td:last-child { + width: 400px; +} /* * Changesets colorization * 1 is the most recent changeset diff --git a/web/js/repos.js b/web/js/repos.js index 9b9dc4bd447..2fdae501a90 100644 --- a/web/js/repos.js +++ b/web/js/repos.js @@ -138,4 +138,5 @@ $(document).ready(function () { return false; }); + domReadyHistory(); }); diff --git a/web/js/utils.js b/web/js/utils.js index acd3d9275d5..375762429ff 100644 --- a/web/js/utils.js +++ b/web/js/utils.js @@ -1483,6 +1483,7 @@ function domReadyHistory() { // I cannot say what will happen if they are not like that, togglediffs // will go mad ! togglerevs(); + toggleProjectInfo(); } function get_annotations() { @@ -1737,21 +1738,21 @@ function toggle_revtags() { } /** - * Function to toggle revision message length for long revision messages + * Function to toggle message length presentation */ -function togglerevs() { +function toggleCommon(closestType) { $(".rev-toggle-a").click(function() { - var toggleState = $(this).closest("p").attr("data-toggle-state"); + var toggleState = $(this).closest(closestType).attr("data-toggle-state"); var thisCell = $(this).closest("td"); - if (toggleState == "less") { - $(this).closest("p").attr("data-toggle-state", "more"); + if (toggleState === "less") { + $(this).closest(closestType).attr("data-toggle-state", "more"); thisCell.find(".rev-message-summary").addClass("rev-message-hidden"); thisCell.find(".rev-message-full").removeClass("rev-message-hidden"); $(this).html("... show less"); } - else if (toggleState == "more") { - $(this).closest("p").attr("data-toggle-state", "less"); + else if (toggleState === "more") { + $(this).closest(closestType).attr("data-toggle-state", "less"); thisCell.find(".rev-message-full").addClass("rev-message-hidden"); thisCell.find(".rev-message-summary").removeClass("rev-message-hidden"); $(this).html("show more ..."); @@ -1761,6 +1762,19 @@ function togglerevs() { }); } +/** + * Function to toggle revision message length for long revision messages + */ +function togglerevs() { + $(".rev-toggle-a").click(toggleCommon("p")); +} +/** + * Function to toggle project info message length + */ +function toggleProjectInfo() { + $(".rev-toggle-a").click(toggleCommon("span")); +} + function selectAllProjects() { if ($("#project").data(SearchableOptionList.prototype.DATA_KEY)) { $("#project").searchableOptionList().selectAll(); diff --git a/web/offwhite/style.css b/web/offwhite/style.css index b8332c8b631..a4ed8c7f3df 100644 --- a/web/offwhite/style.css +++ b/web/offwhite/style.css @@ -215,6 +215,10 @@ label { margin-bottom: 0; } +.panel-body > table tr td:last-child, .panel-body-accordion > table tr td:last-child { + width: 400px; +} + /* * Changesets colorization * 1 is the most recent changeset diff --git a/web/polished/style.css b/web/polished/style.css index dd92394afb2..941c9f53a17 100644 --- a/web/polished/style.css +++ b/web/polished/style.css @@ -233,6 +233,10 @@ label { margin-bottom: 0; } +.panel-body > table tr td:last-child, .panel-body-accordion > table tr td:last-child { + width: 400px; +} + /* * Changesets colorization * 1 is the most recent changeset diff --git a/web/repos.jspf b/web/repos.jspf index 950b47b4291..3a7e9301154 100644 --- a/web/repos.jspf +++ b/web/repos.jspf @@ -131,6 +131,7 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. Mirror SCM type Parent (branch) + Current version @@ -175,8 +176,36 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. if (branch == null) { branch = "N/A"; } + String currentVersion = ri.getCurrentVersion(); + if (currentVersion == null) { + currentVersion = "N/A"; + } %><%= Util.htmlize(type) %><% %><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)<% + %><% + + // Current index collapse threshold minimum of 10 + int summaryLength = Math.max(10, cfg.getCurrentIndexedCollapseThreshold()); + String cout = Util.htmlize(currentVersion); + + boolean showSummary = false; + String coutSummary = currentVersion; + if (coutSummary.length() > summaryLength) { + showSummary = true; + coutSummary = coutSummary.substring(0, summaryLength - 1); + coutSummary = Util.htmlize(coutSummary); + } + if (showSummary) { + %> + <%= coutSummary %> + <%= cout %> + show more ... + <% + } + else { + %><%= cout %><% + } + %><% %><% cnt++; } @@ -224,11 +253,12 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
data-accordion-visible="true"<% } %>> - + + @@ -270,8 +300,37 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. if (branch == null) { branch = "N/A"; } + String currentVersion = ri.getCurrentVersion(); + if (currentVersion == null) { + currentVersion = "N/A"; + } %><% %><% + %><% %><% cnt++; }
Mirror SCM type Parent (branch)Current version
<%= Util.htmlize(type) %><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)<% + + // Current index message collapse threshold minimum of 10 + int summaryLength = Math.max(10, cfg.getCurrentIndexedCollapseThreshold()); + String cout = Util.htmlize(currentVersion); + + boolean showSummary = false; + String coutSummary = currentVersion; + if (coutSummary.length() > summaryLength) { + showSummary = true; + coutSummary = coutSummary.substring(0, summaryLength - 1); + coutSummary = Util.htmlize(coutSummary); + } + + if (showSummary) { + %> + <%= coutSummary %> + <%= cout %> + show more ... + <% + } + else { + %><%= cout %><% + } + %>