现在,我已经做了在GitHub上托管了a small RSS-reading CMS的代码,我就喜欢实现与github上
- 自动检查是否有自动版的自我检查和更新的PHP脚本自身的新版本在主分支
- 允许用户更新该脚本,也就是说,它会覆盖本身与新版本
现在,我已经做了在GitHub上托管了a small RSS-reading CMS的代码,我就喜欢实现与github上
这里是what I came up with(感谢cillosis的答案)
$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;
这样我就不必维护标签,只是比较提交。
应该可以维持在脚本中的当前版本号,然后将其与存储库usi进行比较Repositories API。
你可以得到回购标签,像这样卷曲(更换:用户:回购你的东西):
curl http://github.com/api/v2/json/repos/show/:user/:repo/tags
您可以显示这样的分支:
curl http://github.com/api/v2/json/repos/show/:user/:repo/branches
该API中还有许多其他信息可用。
一旦你得到那个,把它和当前的比较,并进行更新。
那么你遇到了什么问题? – jprofitt 2012-02-15 13:05:27
?那么我不知道从哪里开始!你(我)如何做到这一点?有没有PHP的功能? 是否有一个github的API函数? 它甚至有可能吗? 我有这个页面,index.php,在服务器上A. 而服务器B上的同一页index.php只有更新。 我在serverA/index.php中检查serverB/index.php的版本是什么? – yPhil 2012-02-15 13:12:20