Reputation: 8357
Now that the code for a small RSS-reading CMS that I've done is hosted on github, I'd like it to
Upvotes: 0
Views: 2792
Reputation: 8357
Here is what I came up with (thanks to cillosis's answer)
$commits = json_decode(file_get_contents("https://api.github.com/repos/user_name/repository_name/commits"));
$current_commit_minus1 = $commits[1]->sha;
$ref_commit = "57b75c0f8aefa5ce87c1270265cace18a2347594";
if (!strcmp($current_commit_minus1, $ref_commit))
$moved = true;
else
$moved = false;
That way I don't have to maintain tags, just compare commits.
Upvotes: 4
Reputation: 24549
It should be possible maintaining a current version number within the script, and then comparing it to the repository using the Repositories API.
You can get repo tags with CURL like this (replace :user and :repo with your stuff):
curl http://github.com/api/v2/json/repos/show/:user/:repo/tags
You can show branches like this:
curl http://github.com/api/v2/json/repos/show/:user/:repo/branches
There is a lot of other info available in that API as well.
Once you get that, compare it to the current and procede with updating.
Upvotes: 2