Skip to content

Commit 3638ee3

Browse files
vladakVladimir Kotal
authored andcommitted
unify output format for repository current version
1 parent 0ba7200 commit 3638ee3

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,6 @@ String determineBranch() throws IOException {
704704
return branch;
705705
}
706706

707-
private static final SimpleDateFormat outputDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm");
708-
709707
@Override
710708
public String determineCurrentVersion() throws IOException {
711709
File directory = new File(directoryName);
@@ -737,8 +735,8 @@ public String determineCurrentVersion() throws IOException {
737735

738736
try {
739737
Date date = getDateFormat().parse(output.substring(0, indexOf));
740-
return String.format("%s%s",
741-
new Object[]{outputDateFormat.format(date), output.substring(indexOf)});
738+
return String.format("%s %s",
739+
new Object[]{outputDateFormat.format(date), output.substring(indexOf + 1)});
742740
} catch (ParseException ex) {
743741
throw new IOException(ex);
744742
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public String determineCurrentVersion() throws IOException {
713713
cmd.add("-l");
714714
cmd.add("1");
715715
cmd.add("--template");
716-
cmd.add("{date|isodate}: {node|short} {author} {desc|strip}");
716+
cmd.add("{date|isodate} {node|short} {author} {desc|strip}");
717717

718718
Executor executor = new Executor(cmd, directory);
719719
if (executor.exec(false) != 0) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package org.opensolaris.opengrok.history;
2424

2525
import java.io.Serializable;
26+
import java.text.SimpleDateFormat;
2627

2728
/**
2829
* Class to contain the common info for a repository. This object will live on
@@ -44,6 +45,11 @@ public class RepositoryInfo implements Serializable {
4445
protected String branch;
4546
protected String currentVersion;
4647

48+
/**
49+
* format used for printing the date in {@code currentVersion}
50+
*/
51+
protected static final SimpleDateFormat outputDateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm Z");
52+
4753
/**
4854
* Empty constructor to support serialization.
4955
*/

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,9 @@ public String determineCurrentVersion() throws IOException {
494494
try {
495495
History hist = getHistory(new File(getDirectoryName()), null, 1);
496496
HistoryEntry he = hist.getHistoryEntries().get(0);
497-
curVersion = he.getDate() + ": " + he.getRevision() +
498-
" " + he.getAuthor() + " " + he.getMessage();
497+
curVersion = outputDateFormat.format(he.getDate()) + " " +
498+
he.getRevision() + " " + he.getAuthor() + " " +
499+
he.getMessage();
499500
} catch (HistoryException ex) {
500501
LOGGER.log(Level.WARNING, "cannot get current version info for {0}",
501502
getDirectoryName());

0 commit comments

Comments
 (0)