Skip to content

Commit fd69097

Browse files
committed
Add current indexed version to repos table.
Currently only support for git
1 parent 113f53c commit fd69097

File tree

13 files changed

+181
-10
lines changed

13 files changed

+181
-10
lines changed

src/org/opensolaris/opengrok/configuration/Configuration.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ public final class Configuration {
169169
*/
170170
private int revisionMessageCollapseThreshold;
171171

172+
/**
173+
* Current indexed message will be collapsible if they exceed this many number of
174+
* characters. Front end enforces an appropriate minimum.
175+
*/
176+
private int currentIndexedCollapseThreshold;
177+
178+
172179
/**
173180
* Upper bound for number of threads used for performing multi-project
174181
* searches. This is total for the whole webapp/CLI utility.
@@ -287,6 +294,7 @@ public Configuration() {
287294
setMaxSearchThreadCount(2 * Runtime.getRuntime().availableProcessors());
288295
setIndexRefreshPeriod(60);
289296
setMessageLimit(500);
297+
setCurrentIndexedCollapseThreshold(27);
290298
}
291299

292300
public String getRepoCmd(String clazzName) {
@@ -709,6 +717,14 @@ public int getRevisionMessageCollapseThreshold() {
709717
return this.revisionMessageCollapseThreshold;
710718
}
711719

720+
public int getCurrentIndexedCollapseThreshold() {
721+
return currentIndexedCollapseThreshold;
722+
}
723+
724+
public void setCurrentIndexedCollapseThreshold(int currentIndexedCollapseThreshold) {
725+
this.currentIndexedCollapseThreshold = currentIndexedCollapseThreshold;
726+
}
727+
712728
private transient Date lastModified;
713729

714730
/**

src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,14 @@ public int getMaxSearchThreadCount() {
10881088
return threadConfig.get().getMaxSearchThreadCount();
10891089
}
10901090

1091+
public int getCurrentIndexedCollapseThreshold() {
1092+
return threadConfig.get().getCurrentIndexedCollapseThreshold();
1093+
}
1094+
1095+
public void setCurrentIndexedCollapseThreshold(int currentIndexedCollapseThreshold) {
1096+
threadConfig.get().getCurrentIndexedCollapseThreshold();
1097+
}
1098+
10911099
/**
10921100
* Read an configuration file and set it as the current configuration.
10931101
*

src/org/opensolaris/opengrok/history/GitRepository.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,30 @@ String determineBranch() throws IOException {
662662

663663
return branch;
664664
}
665+
666+
@Override
667+
String determineCurrentVersion() throws IOException {
668+
String line = null;
669+
File directory = new File(directoryName);
670+
671+
List<String> cmd = new ArrayList<>();
672+
ensureCommand(CMD_PROPERTY_KEY, CMD_FALLBACK);
673+
cmd.add(RepoCommand);
674+
cmd.add("log");
675+
cmd.add("-1");
676+
cmd.add("--pretty=%cd: %h %an %s");
677+
cmd.add("--date=format:%Y-%m-%d %H:%M");
678+
ProcessBuilder pb = new ProcessBuilder(cmd);
679+
pb.directory(directory);
680+
Process process;
681+
process = pb.start();
682+
683+
try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
684+
if ((line = in.readLine()) != null) {
685+
line = line.trim();
686+
}
687+
}
688+
689+
return line;
690+
}
665691
}

src/org/opensolaris/opengrok/history/Repository.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opensolaris.opengrok.history;
2424

@@ -364,6 +364,18 @@ final void createCache(HistoryCache cache, String sinceRevision)
364364
*/
365365
abstract String determineBranch() throws IOException;
366366

367+
/**
368+
* Determine and return the current version of the repository.
369+
*
370+
* This operation is consider "heavy" so this function should not be
371+
* called on every web request.
372+
*
373+
* @return the version
374+
*/
375+
String determineCurrentVersion() throws IOException {
376+
return null;
377+
}
378+
367379
/**
368380
* Returns true if this repository supports sub repositories (a.k.a.
369381
* forests).

src/org/opensolaris/opengrok/history/RepositoryFactory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ public static Repository getRepository(File file) throws InstantiationException,
134134
}
135135
}
136136

137+
if (res.getCurrentVersion() == null || res.getCurrentVersion().length() == 0) {
138+
try {
139+
res.setCurrentVersion(res.determineCurrentVersion());
140+
} catch (IOException ex) {
141+
LOGGER.log(Level.WARNING,
142+
"Failed to determineCurrentVersion for {0}: {1}",
143+
new Object[]{file.getAbsolutePath(), ex});
144+
}
145+
}
146+
137147
// If this repository displays tags only for files changed by tagged
138148
// revision, we need to prepare list of all tags in advance.
139149
if (env.isTagsEnabled() && res.hasFileBasedTags()) {

src/org/opensolaris/opengrok/history/RepositoryInfo.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opensolaris.opengrok.history;
2424

@@ -42,6 +42,7 @@ public class RepositoryInfo implements Serializable {
4242
protected String datePattern;
4343
protected String parent;
4444
protected String branch;
45+
protected String currentVersion;
4546

4647
/**
4748
* Empty constructor to support serialization.
@@ -58,6 +59,7 @@ public RepositoryInfo(RepositoryInfo orig) {
5859
this.datePattern = orig.datePattern;
5960
this.parent = orig.parent;
6061
this.branch = orig.branch;
62+
this.currentVersion = orig.currentVersion;
6163
}
6264

6365
/**
@@ -167,4 +169,12 @@ public String getBranch() {
167169
public void setBranch(String branch) {
168170
this.branch = branch;
169171
}
172+
173+
public String getCurrentVersion() {
174+
return currentVersion;
175+
}
176+
177+
public void setCurrentVersion(String currentVersion) {
178+
this.currentVersion = currentVersion;
179+
}
170180
}

src/org/opensolaris/opengrok/web/PageConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ public int getRevisionMessageCollapseThreshold() {
477477
return getEnv().getRevisionMessageCollapseThreshold();
478478
}
479479

480+
public int getCurrentIndexedCollapseThreshold() {
481+
return getEnv().getCurrentIndexedCollapseThreshold();
482+
}
483+
480484
/**
481485
* Get sort orders from the request parameter {@code sort} and if this list
482486
* would be empty from the cookie {@code OpenGrokorting}.

web/default/style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ label {
215215
margin-bottom: 0;
216216
}
217217

218+
.panel-body > table tr td:last-child, .panel-body-accordion > table tr td:last-child {
219+
width: 400px;
220+
}
218221
/*
219222
* Changesets colorization
220223
* 1 is the most recent changeset

web/js/repos.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,5 @@ $(document).ready(function () {
138138

139139
return false;
140140
});
141+
domReadyHistory();
141142
});

web/js/utils.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,7 @@ function domReadyHistory() {
14831483
// I cannot say what will happen if they are not like that, togglediffs
14841484
// will go mad !
14851485
togglerevs();
1486+
toggleProjectInfo();
14861487
}
14871488

14881489
function get_annotations() {
@@ -1737,21 +1738,21 @@ function toggle_revtags() {
17371738
}
17381739

17391740
/**
1740-
* Function to toggle revision message length for long revision messages
1741+
* Function to toggle message length presentation
17411742
*/
1742-
function togglerevs() {
1743+
function toggleCommon(closestType) {
17431744
$(".rev-toggle-a").click(function() {
1744-
var toggleState = $(this).closest("p").attr("data-toggle-state");
1745+
var toggleState = $(this).closest(closestType).attr("data-toggle-state");
17451746
var thisCell = $(this).closest("td");
17461747

1747-
if (toggleState == "less") {
1748-
$(this).closest("p").attr("data-toggle-state", "more");
1748+
if (toggleState === "less") {
1749+
$(this).closest(closestType).attr("data-toggle-state", "more");
17491750
thisCell.find(".rev-message-summary").addClass("rev-message-hidden");
17501751
thisCell.find(".rev-message-full").removeClass("rev-message-hidden");
17511752
$(this).html("... show less");
17521753
}
1753-
else if (toggleState == "more") {
1754-
$(this).closest("p").attr("data-toggle-state", "less");
1754+
else if (toggleState === "more") {
1755+
$(this).closest(closestType).attr("data-toggle-state", "less");
17551756
thisCell.find(".rev-message-full").addClass("rev-message-hidden");
17561757
thisCell.find(".rev-message-summary").removeClass("rev-message-hidden");
17571758
$(this).html("show more ...");
@@ -1761,6 +1762,19 @@ function togglerevs() {
17611762
});
17621763
}
17631764

1765+
/**
1766+
* Function to toggle revision message length for long revision messages
1767+
*/
1768+
function togglerevs() {
1769+
$(".rev-toggle-a").click(toggleCommon("p"));
1770+
}
1771+
/**
1772+
* Function to toggle project info message length
1773+
*/
1774+
function toggleProjectInfo() {
1775+
$(".rev-toggle-a").click(toggleCommon("span"));
1776+
}
1777+
17641778
function selectAllProjects() {
17651779
if ($("#project").data(SearchableOptionList.prototype.DATA_KEY)) {
17661780
$("#project").searchableOptionList().selectAll();

0 commit comments

Comments
 (0)