我能够获取 commits 的列表(带有 commit messages , oid , commit url 之类的字段>等)以及在changedFiles
分支上的存储库中生成的master
的数量。
但是,我无法弄清楚如何有关更改本身和更改的文件的任何信息。
在REST API的v3中,有关更改的信息包含在files
-> patch
和files
-> raw_url
或blob_url
中在该阶段提供了有关原始文件本身的信息。
Q)在使用GraphQL的GitHub API的v4中,如何获取相应的信息?
查询我现在坚持使用(为简洁起见,仅显示1次提交)-
query {
rateLimit{
cost
remaining
}
repository(owner: "elastic", name: "elasticsearch") {
name
defaultBranchRef {
name
target {
... on Commit {
history(first:1){
nodes{
message
changedFiles
id
oid
treeUrl
url
tree{
oid
}
}
pageInfo{
hasNextPage
startCursor
endCursor
}
}
}
}
}
}
}
输出:
{
"data": {
"rateLimit": {
"cost": 1,
"remaining": 4999
},
"repository": {
"name": "elasticsearch",
"defaultBranchRef": {
"name": "master",
"target": {
"history": {
"nodes": [
{
"message": "Small corrections to HLRC doc for _termvectors (#35221)\n\nRelates to #33447",
"changedFiles": 2,
"id": "MDY6Q29tbWl0NTA3Nzc1OmEyYzIyYWQ3YWViMGY4ZDUxNDg2NzdkZDcyMjJhZDQzYWZlZTlhMTc=",
"oid": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"treeUrl": "https://github.com/elastic/elasticsearch/tree/a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"url": "https://github.com/elastic/elasticsearch/commit/a2c22ad7aeb0f8d5148677dd7222ad43afee9a17",
"tree": {
"oid": "4f5f11e0e55aeafc4677800959232726a2cd787c"
}
}
],
"pageInfo": {
"hasNextPage": true,
"startCursor": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17 0",
"endCursor": "a2c22ad7aeb0f8d5148677dd7222ad43afee9a17 0"
}
}
}
}
}
}
}