@@ -78,6 +78,12 @@ public class GitRepository extends Repository {
78
78
private static final String ABBREV_LOG = "--abbrev=" + CSET_LEN ;
79
79
private static final String ABBREV_BLAME = "--abbrev=" + (CSET_LEN - 1 );
80
80
81
+ /**
82
+ * All git commands that emit date that needs to be parsed by
83
+ * {@code getDateFormat()} should use this option.
84
+ */
85
+ private static final String GIT_DATE_OPT = "--date=iso8601-strict" ;
86
+
81
87
/**
82
88
* Pattern used to extract author/revision from git blame.
83
89
*/
@@ -123,7 +129,7 @@ Executor getHistoryLogExecutor(final File file, String sinceRevision)
123
129
cmd .add (ABBREV_LOG );
124
130
cmd .add ("--name-only" );
125
131
cmd .add ("--pretty=fuller" );
126
- cmd .add ("--date=iso8601-strict" );
132
+ cmd .add (GIT_DATE_OPT );
127
133
128
134
if (file .isFile () && RuntimeEnvironment .getInstance ().isHandleHistoryOfRenamedFiles ()) {
129
135
cmd .add ("--follow" );
@@ -704,20 +710,25 @@ String determineBranch() throws IOException {
704
710
String determineCurrentVersion () throws IOException {
705
711
File directory = new File (directoryName );
706
712
List <String > cmd = new ArrayList <>();
713
+ // The delimiter must not be contained in the date format emitted by
714
+ // {@code GIT_DATE_OPT}.
715
+ String delim = "#" ;
716
+
707
717
ensureCommand (CMD_PROPERTY_KEY , CMD_FALLBACK );
718
+
708
719
cmd .add (RepoCommand );
709
720
cmd .add ("log" );
710
721
cmd .add ("-1" );
711
- cmd .add ("--pretty=%cd: %h %an %s" );
712
- cmd .add ("--date=rfc" );
722
+ cmd .add ("--pretty=%cd" + delim + " %h %an %s" );
723
+ cmd .add (GIT_DATE_OPT );
713
724
714
725
Executor executor = new Executor (cmd , directory );
715
726
if (executor .exec (false ) != 0 ) {
716
727
throw new IOException (executor .getErrorString ());
717
728
}
718
729
719
730
String output = executor .getOutputString ().trim ();
720
- int indexOf = StringUtils .nthIndexOf (output , ":" , 3 );
731
+ int indexOf = StringUtils .nthIndexOf (output , delim , 1 );
721
732
if (indexOf < 0 ) {
722
733
throw new IOException (
723
734
String .format ("Couldn't extract date from \" %s\" ." ,
0 commit comments