Skip to content

Add current indexed version to repos table. #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/org/opensolaris/opengrok/configuration/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -287,6 +294,7 @@ public Configuration() {
setMaxSearchThreadCount(2 * Runtime.getRuntime().availableProcessors());
setIndexRefreshPeriod(60);
setMessageLimit(500);
setCurrentIndexedCollapseThreshold(27);
}

public String getRepoCmd(String clazzName) {
Expand Down Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
26 changes: 26 additions & 0 deletions src/org/opensolaris/opengrok/history/GitRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,30 @@ String determineBranch() throws IOException {

return branch;
}

@Override
String determineCurrentVersion() throws IOException {
String line = null;
File directory = new File(directoryName);

List<String> 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;
}
}
14 changes: 13 additions & 1 deletion src/org/opensolaris/opengrok/history/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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).
Expand Down
10 changes: 10 additions & 0 deletions src/org/opensolaris/opengrok/history/RepositoryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
12 changes: 11 additions & 1 deletion src/org/opensolaris/opengrok/history/RepositoryInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -42,6 +42,7 @@ public class RepositoryInfo implements Serializable {
protected String datePattern;
protected String parent;
protected String branch;
protected String currentVersion;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong copyright date.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


/**
* Empty constructor to support serialization.
Expand All @@ -58,6 +59,7 @@ public RepositoryInfo(RepositoryInfo orig) {
this.datePattern = orig.datePattern;
this.parent = orig.parent;
this.branch = orig.branch;
this.currentVersion = orig.currentVersion;
}

/**
Expand Down Expand Up @@ -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;
}
}
4 changes: 4 additions & 0 deletions src/org/opensolaris/opengrok/web/PageConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
3 changes: 3 additions & 0 deletions web/default/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions web/js/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ $(document).ready(function () {

return false;
});
domReadyHistory();
});
28 changes: 21 additions & 7 deletions web/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 ...");
Expand All @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions web/offwhite/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions web/polished/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 60 additions & 1 deletion web/repos.jspf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
<td><b>Mirror</b></td>
<td><b>SCM type</b></td>
<td><b>Parent (branch)</b></td>
<td><b>Current version</b></td>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -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";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%><td><%

// 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) {
%>
<span class="rev-message-summary"><%= coutSummary %></span>
<span class="rev-message-full rev-message-hidden"><%= cout %></span>
<span data-toggle-state="less"><a class="rev-toggle-a rev-message-toggle " href="#">show more ... </a></span>
<%
}
else {
%><span class="rev-message-full"><%= cout %></span><%
}
%></td><%
%></tr><%
cnt++;
}
Expand Down Expand Up @@ -224,11 +253,12 @@ Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
<div class="panel-body<% if (groups.size() > 0) {%>-accordion<% } %> <% if (pHelper.hasUngroupedFavourite()) { %> favourite<% } %>"
<% if (pHelper.hasUngroupedFavourite()) { %>data-accordion-visible="true"<% } %>>
<table>
<thead>
<thead>
<tr>
<td><b>Mirror</b></td>
<td><b>SCM type</b></td>
<td><b>Parent (branch)</b></td>
<td><b>Current version</b></td>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two places in repos.jspf where a line about repository is being printed to the output. So this should be handled in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

if (currentVersion == null) {
currentVersion = "N/A";
}
%><td><%= Util.htmlize(type) %></td><%
%><td><%= Util.htmlize(parent) %> (<%= Util.htmlize(branch) %>)</td><%
%><td><%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it looks like this:
screenshot from 2016-11-04 12-24-41

Which has not really necessary margin, can you avoid this?

Copy link
Contributor Author

@amotzte amotzte Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to set the table column to be at fixed size so in case user choose to open the "show more..." it will not change the other columns size (which feel annoying in the eye..). Currently they are divided with default size (each column get the exact some size). I guess I can reduce the size of "SCM type" to something smaller but still fixed and give more space to "Parent (branch)" and "Current version". I'll give it a try.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more talking about this, which is not like it was before (there was just single line with no margin). It's solved for me by replacing <p> with <span> however then the "show more" link does not work.

screenshot from 2016-11-04 12-24-41

You can restrict the scm column to some small percentage of the width, and also you always know what is the longest scm supported by OpenGrok.

Copy link
Contributor Author

@amotzte amotzte Nov 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed
@tulinkry, I set only "Current version" to be fixed so the rest can adjust according to their size. I also fixed the extra margins. See new screenshots.

screen shot 2016-11-06 at 8 55 04 am

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to stay with the one line like this:
screenshot from 2016-11-10 16-51-57

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


// 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) {
%>
<span class="rev-message-summary"><%= coutSummary %></span>
<span class="rev-message-full rev-message-hidden"><%= cout %></span>
<span data-toggle-state="less"><a class="rev-toggle-a rev-message-toggle " href="#">show more ... </a></span>
<%
}
else {
%><span class="rev-message-full"><%= cout %></span><%
}
%></td><%
%></tr><%
cnt++;
}
Expand Down