我正在使用 request.get 来获取 Json,并想使用最新的补丁集和扩展名 /revisions/(patchSetNumber)/files 再次执行此操作以查找所有修改的文件。我不知道如何通过请求找到补丁集 ID。
我尝试通过 url/details 扩展进行搜索,但无法找到修订选项卡或补丁集选项卡
根据文档,您可以指定
ALL_REVISIONS
选项来获取与更改相关的所有修订版本的列表,例如对于此更改,我们可以获得这样的修订列表(tail -c+5
是因为 REST 响应有问题):
curl -s 'https://review.opendev.org/changes/918316?o=ALL_REVISIONS' |
tail -c+5 |
jq -r '.revisions|keys'
这会产生:
[
"14e0f2b73995510d7bd2b0eb84f3b71b92203c78",
"1bb00656eed24ca7de9f35868910d3c301d8114a",
"85cebfa4775da4cff725e017e29d2bcba6691642",
"8831400ebcfe6cfb64526ce92830f574eb826f5e",
"9d9b03b71a4a0e87321881e5a562d995ae5cf0d9",
"a0c5cf5ff7a2e18524bc68a10fe82b811d56868e",
"bd657d0b31152ed3fd2b147bfb1b6e2b0a279bac",
"cab2417cd4d4f0f7595a1d843dfb44c0410b3a75",
"d4e653fb2b1ff54298a1262dfc397cc29e845985",
"d75f457e0e68fbd6a31bca76143264b623ff73bf",
"f16f39564f2c55584c4ff28abc0d4b48d796c508"
]
我们可以使用这些修订 ID 来获取有关每个补丁集的详细信息:
$ curl -s 'https://review.opendev.org/changes/918316/revisions/14e0f2b73995510d7bd2b0eb84f3b71b92203c78/files' |
tail -c+5 |
jq
这让我们:
{
"/COMMIT_MSG": {
"status": "A",
"lines_inserted": 12,
"size_delta": 483,
"size": 483
},
"cinder/db/migrations/versions/a8189e5afd9a_add_volume_type_metadata_table.py": {
"status": "A",
"new_mode": 33188,
"lines_inserted": 53,
"size_delta": 1601,
"size": 1601
},
"cinder/db/sqlalchemy/models.py": {
"old_mode": 33188,
"new_mode": 33188,
"lines_inserted": 27,
"size_delta": 784,
"size": 41911
},
"cinder/tests/unit/db/test_migrations.py": {
"old_mode": 33188,
"new_mode": 33188,
"lines_inserted": 5,
"size_delta": 224,
"size": 19916
}
}
在 Python 中,这看起来像:
>>> res=requests.get('https://review.opendev.org/changes/918316/revisions/14e0f2b73995510d7bd2b0eb84f3b71b92203c78/files')
>>> data=json.loads(res.text[5:])
>>> list(data.keys())
['/COMMIT_MSG',
'cinder/db/migrations/versions/a8189e5afd9a_add_volume_type_metadata_table.py',
'cinder/db/sqlalchemy/models.py',
'cinder/tests/unit/db/test_migrations.py']