Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
fix version reading issue with double-digit version numbers (ie. 1.10.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
AusHick committed Nov 9, 2018
1 parent a7c2a69 commit 8438ec3
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/net/sf/statsvn/util/SvnStartupUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class SvnStartupUtils implements ISvnVersionProcessor {
private static final String SVN_VERSION_COMMAND = "svn --version";

public static final String SVN_MINIMUM_VERSION = "1.3.0";
public static final String SVN_MINIMUM_VERSION = "1.3.10";

public static final String SVN_MINIMUM_VERSION_DIFF_PER_REV = "1.4.0";

Expand Down Expand Up @@ -60,13 +60,38 @@ public synchronized String checkSvnVersionSufficient() throws SvnVersionMismatch
final Matcher m = pRegex.matcher(line);
if (m.find()) {
final String versionString = line.substring(m.start(), m.end());

final String curVersion[] = versionString.split("\\.");
final String minVersion[] = SVN_MINIMUM_VERSION.split("\\.");
boolean versionSuccess = false;

for (int i = 0; i < Math.min(minVersion.length, curVersion.length); i++) {
final int curVersionNum = Integer.parseInt(curVersion[i]);
final int minVersionNum = Integer.parseInt(minVersion[i]);

if(curVersionNum == minVersionNum) {
continue;
} else if (curVersionNum > minVersionNum) {
versionSuccess = true;
break;
} else if (curVersionNum < minVersionNum) {
versionSuccess = false;
break;
}
}

if (versionSuccess) {
return versionString;
} else {
throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
}
/*
// we perform a simple string comparison against the version numbers
if (versionString.compareTo(SVN_MINIMUM_VERSION) >= 0) {
return versionString; // success
} else {
throw new SvnVersionMismatchException(versionString, SVN_MINIMUM_VERSION);
}
*/
}
}
}
Expand Down

0 comments on commit 8438ec3

Please sign in to comment.