Support updating branch via API (#35951)

Resolve #35368
This commit is contained in:
Lunny Xiao
2025-12-10 11:23:26 -08:00
committed by GitHub
parent 24b81ac8b9
commit a440116a16
8 changed files with 321 additions and 7 deletions

View File

@@ -6750,6 +6750,66 @@
}
}
},
"put": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Update a branch reference to a new commit",
"operationId": "repoUpdateBranch",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the branch",
"name": "branch",
"in": "path",
"required": true
},
{
"name": "body",
"in": "body",
"schema": {
"$ref": "#/definitions/UpdateBranchRepoOption"
}
}
],
"responses": {
"204": {
"$ref": "#/responses/empty"
},
"403": {
"$ref": "#/responses/forbidden"
},
"404": {
"$ref": "#/responses/notFound"
},
"409": {
"$ref": "#/responses/conflict"
},
"422": {
"$ref": "#/responses/validationError"
}
}
},
"delete": {
"produces": [
"application/json"
@@ -28702,6 +28762,31 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"UpdateBranchRepoOption": {
"description": "UpdateBranchRepoOption options when updating a branch reference in a repository",
"type": "object",
"required": [
"new_commit_id"
],
"properties": {
"force": {
"description": "Force update even if the change is not a fast-forward",
"type": "boolean",
"x-go-name": "Force"
},
"new_commit_id": {
"description": "New commit SHA (or any ref) the branch should point to",
"type": "string",
"x-go-name": "NewCommitID"
},
"old_commit_id": {
"description": "Expected old commit SHA of the branch; if provided it must match the current tip",
"type": "string",
"x-go-name": "OldCommitID"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
"UpdateFileOptions": {
"description": "UpdateFileOptions options for updating or creating a file\nNote: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used)",
"type": "object",