如何在重命名后找到存储库的新位置 [英] How to find the new location of a repository after a rename
问题描述
如果用户通过GitHub的UI将存储库从 foo / bar.git
重命名为 foo / baz.git
,我怎么能通过API检测到这一点?
目前,如果我像这样调用API,我会得到一个404:
GET / repos / foo / bar
我可以找到新的存储库名称吗?
因此,GitHub不会通过API暴露重命名。 b
更新:这不再是真实的,并且此答案已过时; 自2015年7月起API已经公开重命名 考虑到您的问题的限制(即只更改了存储库名称,而不是用户/组织),您可以依赖存储库ID。 / p> 如果您在重命名之前有关于repo的信息,则应该有API返回的id。如果你确实有弹性访问版本库的权限,你只需要做 无论名称是否更改(假设您仍然可以访问它),您将始终获取存储库, 。 更好的例子是, //api.github.com/repositories/1234 (或者任何你的GitHub企业实例)。 If a user renames a repository from Currently, I get a 404 if I call the API like this: How can I find the new repository name? So GitHub does not expose renames through the API. UPDATE: that is no longer true and this answer is out of date; the API has exposed renames since July 2015. Given the constraints of your question (i.e., just the repository name has changed, not the user/organization) you could rely on the repository ID. If you have information about the repo before it was renamed, you should have the id which is returned by the API. If you do then to have a resilient access to the repository, you just need to do And you'll always get the repository, regardless of whether the name changes (assuming you still have access to it). A better example, is to do (or whatever your GitHub enterprise instance is). 这篇关于如何在重命名后找到存储库的新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
GET / repositories / 1234
foo/bar.git
to foo/baz.git
via GitHub's UI, how can I detect this via the API?GET /repos/foo/bar
GET /repositories/1234
GET https://api.github.com/repositories/1234