GitHub API:确定包含给定提交的分支 [英] GitHub API: Identify the branches that contain a given commit

查看:62
本文介绍了GitHub API:确定包含给定提交的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到我的仓库中特定提交的SHA,我想使用GitHub API 标识包含提交的分支.

Given the SHA of a specific commit in my repo, I want to identify the branches which contain the commit, using the GitHub API.

我知道我可以直接通过 git 在本地进行多种操作,包括

I'm aware I can do this locally using git directly in a variety of ways, including

git branch --contains <commit>

但这是针对从多个平台提取数据的集成页面,因此我确实需要使用API​​.

but this is for an integrated page that's pulling data from several platforms, so I really need to be using the API.

此问题已被接受回答说这在2013年是不可能的,但是我希望从那时起这些方面的东西已经被添加到API中.

This question had an accepted answer saying this wasn't possible back in 2013, but I'm hoping something along these lines has been added to the API since.

有人知道在查询所需分支中的所有提交列表并对其进行遍历以进行比较的情况下缺少此信息的方法吗?

Is anyone aware of a way to get this information short of querying for a list of ALL commits in the branches of interest and iterating through them to compare?

推荐答案

没有一个存储库提交 Git提交 Git引用端点都提供该数据,所以我认为API只是不这样做.

None of the Repository Commit, Git Commit nor Git References endpoints provide that data, so I think the API just doesn't do it.

但是网站会显示该数据,因此,如果您迫切需要它,则可以尝试抓取提交的页面( https://github.com/:user/:repo/commit/:sha ),并获取 commit-branches div.

But the website shows that data, so if you desperately need it you could try scraping the commit's page (https://github.com/:user/:repo/commit/:sha) and getting the commit-branches div.

最后,Github的支持很棒,所以您应该问他们-最坏的情况是他们告诉您它尚未实现,但也许他们将它列在TO-DO列表中.

Finally, Github's Support is great, so you should ask them - worst-case scenario is they tell you it's not implemented, but maybe they put it on the TO-DO list.

这篇关于GitHub API:确定包含给定提交的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆