GitProtocolV2IT: Fix git version check for Google environment
At Google we use custom Git versions that have a version such as "x.y.z.gXXXXXXXXXX-goog". Trying to parse the last part as number fails. To make the Git version check pass, ignore the Google specific part of the version. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: Ic5185f58836fb803c825ae4cb08bb765e0531108
This commit is contained in:
@@ -37,10 +37,11 @@ public class GitClientVersion implements Comparable<GitClientVersion> {
|
|||||||
* @param version String returned by git version command
|
* @param version String returned by git version command
|
||||||
*/
|
*/
|
||||||
public GitClientVersion(String version) {
|
public GitClientVersion(String version) {
|
||||||
// "git version x.y.z"
|
// "git version x.y.z", at Google "git version x.y.z.gXXXXXXXXXX-goog"
|
||||||
String parts[] = version.split(" ")[2].split("\\.");
|
String parts[] = version.split(" ")[2].split("\\.");
|
||||||
v = new int[parts.length];
|
int numParts = Math.min(parts.length, 3); // ignore Google-specific part of the version
|
||||||
for (int i = 0; i < parts.length; i++) {
|
v = new int[numParts];
|
||||||
|
for (int i = 0; i < numParts; i++) {
|
||||||
v[i] = Integer.valueOf(parts[i]);
|
v[i] = Integer.valueOf(parts[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user