问题描述
我写了一个 Firefox extension 来让 Github“分叉”页面更有用。我需要为每个分叉提交前/后数据。
为了正确地做到这一点,我尝试通过 jQuery AJAX 请求使用 Github REST API:
const url = `https://api.github.com/repos/${parent_owner}/${repo_name}/compare/${parent_branch}...${child_owner}:${child_branch}`;
console.log(url);
$.ajax({
url: url,async: false,headers: {
Accept: "application/vnd.github.v3+json",Authorization: `token ${token}`
},success : function(response) {
const commits_ahead = response.ahead_by;
const commits_behind = response.behind_by;
const status = response.status;
console.log(`ahead: ${commits_ahead},behind: ${commits_behind},status: ${status}`);
},error : function(jqXHR,textStatus,errorThrown){
console.log(errorThrown);
}
});
但 Github 显示了无法与父级比较的 fork repos 上的提交前/后数据,例如:https://github.com/1292765944/tensorflow
还有其他方法可以通过 Github REST API 获取此类数据吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)