Skip to content

Commit

Permalink
updated version check to allow for patches
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansen4857 committed Oct 3, 2018
1 parent 8493249 commit 59e3a20
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/org/rangerrobotics/pathplanner/PathPlanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
import org.rangerrobotics.pathplanner.gui.MainScene;
Expand Down Expand Up @@ -40,11 +41,29 @@ public void start(Stage stage){
GitHub github = GitHub.connectAnonymously();
GHRepository repo = github.getRepository("mjansen4857/PathPlanner");
String lastReleaseVersion = repo.getLatestRelease().getTagName().substring(1);
int num = StringUtils.countMatches(lastReleaseVersion, '.');
int major = Integer.parseInt(lastReleaseVersion.substring(0, lastReleaseVersion.indexOf(".")));
int minor = Integer.parseInt(lastReleaseVersion.substring(lastReleaseVersion.indexOf(".") + 1));
int minor;
int patch;
if(num == 2){
minor = Integer.parseInt(lastReleaseVersion.substring(lastReleaseVersion.indexOf(".") + 1, lastReleaseVersion.lastIndexOf(".")));
patch = Integer.parseInt(lastReleaseVersion.substring(lastReleaseVersion.lastIndexOf(".") + 1));
}else{
minor = Integer.parseInt(lastReleaseVersion.substring(lastReleaseVersion.indexOf(".") + 1));
patch = 0;
}
int thisNum = StringUtils.countMatches(VERSION, '.');
int thisMajor = Integer.parseInt(VERSION.substring(1, VERSION.indexOf(".")));
int thisMinor = Integer.parseInt(VERSION.substring(VERSION.indexOf(".") + 1));
if(major > thisMajor || (major == thisMajor && minor > thisMinor)){
int thisMinor;
int thisPatch;
if(thisNum == 2){
thisMinor = Integer.parseInt(VERSION.substring(VERSION.indexOf(".") + 1, VERSION.lastIndexOf(".")));
thisPatch = Integer.parseInt(VERSION.substring(VERSION.lastIndexOf(".") + 1));
}else{
thisMinor = Integer.parseInt(VERSION.substring(VERSION.indexOf(".") + 1));
thisPatch = 0;
}
if(major > thisMajor || minor > thisMinor || patch > thisPatch){
MainScene.showUpdateSnackbar("PathPlanner v" + lastReleaseVersion + " is now available!");
}
}catch(IOException e){
Expand Down

0 comments on commit 59e3a20

Please sign in to comment.