- this.major = Integer.parseInt(tab[0]);
- this.minor = Integer.parseInt(tab[1]);
- this.patch = Integer.parseInt(tab[2]);
- this.version = version;
+ this.major = Integer.parseInt(tab[0].trim());
+ this.minor = Integer.parseInt(tab[1].trim());
+ if (tab[2].contains("-")) {
+ int posInVersion = version.indexOf('.');
+ posInVersion = version.indexOf('.', posInVersion + 1);
+ String rest = version.substring(posInVersion + 1);
+
+ int posInRest = rest.indexOf('-');
+ this.patch = Integer.parseInt(rest.substring(0, posInRest)
+ .trim());
+
+ posInVersion = version.indexOf('-');
+ this.tag = version.substring(posInVersion + 1).trim();
+ this.tagVersion = -1;
+
+ StringBuilder str = new StringBuilder();
+ while (!tag.isEmpty() && tag.charAt(tag.length() - 1) >= '0'
+ && tag.charAt(tag.length() - 1) <= '9') {
+ str.insert(0, tag.charAt(tag.length() - 1));
+ tag = tag.substring(0, tag.length() - 1);
+ }
+
+ if (str.length() > 0) {
+ this.tagVersion = Integer.parseInt(str.toString());
+ }
+ } else {
+ this.patch = Integer.parseInt(tab[2].trim());
+ this.tag = null;
+ this.tagVersion = -1;
+ }
+
+ this.version = generateVersion();