简体   繁体   English

如何在GitHub中获取某个版本的所有提交?

[英]How to get all commits for a certain release in GitHub?

I know I can get all commits in a project using GET /repos/:owner/:repo/commits 我知道我可以用得到项目中的所有提交 GET /repos/:owner/:repo/commits

Now I want to get all commits for a certain release of that project . 现在,我想获取该项目特定版本的所有提交

What should I do? 我该怎么办?

Judging by your answer to my question, you want the commits made since some tag. 从您对我的问题的回答来看,您需要某个标记以来所做的提交。 This will take a couple steps to complete, first you need to get the SHA for the tag in question. 这将需要完成几个步骤,首先,您需要获取有问题的标签的SHA。 You'll want to use the git references API to get a specific reference . 您将要使用git引用API获取特定的引用 In the specific example that you linked you'll want to do 在您链接的特定示例中,您将要做

GET /repos/nasa/mct/git/refs/tags/v1.8b3

And you'll want to get the 'sha' attribute from the object stored in the 'object' attribute of the response object. 您将需要从存储在响应对象的'object'属性中的对象获取'sha'属性。 With the 'sha' attribute, you'll want to use the commits API to list commits starting with that 'sha' so your request will look like this: 使用'sha'属性,您将要使用commits API 列出以该'sha'开头的提交,因此您的请求将如下所示:

GET /repos/nasa/mct/commits?sha=%(sha_from_first_request)s

That will give you 30 commits per-page by default (if I remember correctly), so you should see if adding &per_page=100 to the end helps. 默认情况下,这将使您每页30次提交(如果我没记错的话),因此您应该看看在最后添加&per_page=100是否有帮助。 I can't tell you exactly how to do this in Java, but I expect you'll be able to use one of the libraries written to interact with the API to make it easier. 我无法确切地告诉您如何用Java做到这一点,但是我希望您能够使用编写的一种库与API进行交互,以使其变得更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM