仓库子模块 API
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
更新仓库中现有的子模块引用
在一些工作流程中,尤其是自动化流程中,可以更新子模块的引用以保持使用它的其他项目的最新状态。此端点允许您在特定分支中更新 Git 子模块 的引用。
plaintextPUT /projects/:id/repository/submodules/:submodule
| 属性 | 类型 | 必需 | 描述 |
|---|---|---|---|
| id | integer/string | 是 | 项目的 ID 或 URL 编码路径 |
| submodule | string | 是 | 子模块的 URL 编码完整路径。例如,lib%2Fclass%2Erb |
| branch | string | 是 | 要提交到的分支名称 |
| commit_sha | string | 是 | 更新子模块到的完整提交 SHA |
| commit_message | string | 否 | 提交信息。如果没有提供信息,则设置为默认值 |
shellcurl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/repository/submodules/lib%2Fmodules%2Fexample" \ --data "branch=main&commit_sha=3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88&commit_message=Update submodule reference"
示例响应:
json1{ 2 "id": "ed899a2f4b50b4370feeea94676502b42383c746", 3 "short_id": "ed899a2f4b5", 4 "title": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88", 5 "author_name": "Dmitriy Zaporozhets", 6 "author_email": "dzaporozhets@sphereconsultinginc.com", 7 "committer_name": "Dmitriy Zaporozhets", 8 "committer_email": "dzaporozhets@sphereconsultinginc.com", 9 "created_at": "2018-09-20T09:26:24.000-07:00", 10 "message": "Updated submodule example_submodule with oid 3ddec28ea23acc5caa5d8331a6ecb2a65fc03e88", 11 "parent_ids": [ 12 "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" 13 ], 14 "committed_date": "2018-09-20T09:26:24.000-07:00", 15 "authored_date": "2018-09-20T09:26:24.000-07:00", 16 "status": null 17}