Skip to content

Commit

Permalink
fix check of new releases; fix #163
Browse files Browse the repository at this point in the history
  • Loading branch information
orthagh committed Oct 13, 2015
1 parent be45cd3 commit a4177b9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,17 @@ static function checkNewVersionAvailable($auto=true, $messageafterredirect=false
echo "<br>";
}

//parse github releases
$error = "";
$latest_version = self::getURLContent("http://glpi-project.org/latest_version", $error);
$json_gh_tags = self::getURLContent("https://api.github.com/repos/glpi-project/glpi/tags", $error);
$all_gh_tags = json_decode($json_gh_tags, true);
$released_tags = array();
foreach ($all_gh_tags as $tag) {
if (!preg_match("/[beta|rc]/i", $tag['name'])) {
$released_tags[] = $tag['name'];
}
}
$latest_version = array_shift($released_tags);

if (strlen(trim($latest_version)) == 0) {
if (!$auto) {
Expand Down

3 comments on commit a4177b9

@remicollet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should parse https://api.github.com/repos/glpi-project/glpi/releases instead.

And see "prerelease" attribute (notice, IIRC, prelease are not in the answer if you are not connected, with collaborator rights)

@remicollet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think that taking the first found release/tag is not correct (we can imagine releasing a 0.85.6 'after" a 0.90.1, so it would appear first)

@orthagh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true for order, for releases, maybe it's better with the prerelease attributes.
I'll change for that

Please sign in to comment.