I write a Firefox extension to make Github "Forks" page more useful. I need commits ahead/behind data for each fork.
To do so right way, I tried to use Github REST API through jQuery AJAX requests:
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);
}
});
But Github shows commits ahead/behind data on fork repos that cannot be compared to parent, for example: https://github.com/1292765944/tensorflow
Is there another way to get such data through Github REST API?
question from:
https://stackoverflow.com/questions/65651776/how-to-use-github-v3-api-to-get-commits-ahead-behind-data-for-forks-that-cannot 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…