Rename UpdateBranch API to RenameBranch API (#35374)

Discussed in #35368, originally implemented in #32433
This commit is contained in:
Michal Suchánek
2025-09-01 16:12:05 +00:00
committed by GitHub
parent fd7ebaf427
commit ea96ff6b0c
6 changed files with 47 additions and 47 deletions

View File

@@ -1256,7 +1256,7 @@ func Routes() *web.Router {
m.Get("/*", repo.GetBranch)
m.Delete("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.DeleteBranch)
m.Post("", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.CreateBranchRepoOption{}), repo.CreateBranch)
m.Patch("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.UpdateBranchRepoOption{}), repo.UpdateBranch)
m.Patch("/*", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, bind(api.RenameBranchRepoOption{}), repo.RenameBranch)
}, context.ReferencesGitRepo(), reqRepoReader(unit.TypeCode))
m.Group("/branch_protections", func() {
m.Get("", repo.ListBranchProtections)

View File

@@ -380,11 +380,11 @@ func ListBranches(ctx *context.APIContext) {
ctx.JSON(http.StatusOK, apiBranches)
}
// UpdateBranch updates a repository's branch.
func UpdateBranch(ctx *context.APIContext) {
// swagger:operation PATCH /repos/{owner}/{repo}/branches/{branch} repository repoUpdateBranch
// RenameBranch renames a repository's branch.
func RenameBranch(ctx *context.APIContext) {
// swagger:operation PATCH /repos/{owner}/{repo}/branches/{branch} repository repoRenameBranch
// ---
// summary: Update a branch
// summary: Rename a branch
// consumes:
// - application/json
// produces:
@@ -408,7 +408,7 @@ func UpdateBranch(ctx *context.APIContext) {
// - name: body
// in: body
// schema:
// "$ref": "#/definitions/UpdateBranchRepoOption"
// "$ref": "#/definitions/RenameBranchRepoOption"
// responses:
// "204":
// "$ref": "#/responses/empty"
@@ -419,7 +419,7 @@ func UpdateBranch(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
opt := web.GetForm(ctx).(*api.UpdateBranchRepoOption)
opt := web.GetForm(ctx).(*api.RenameBranchRepoOption)
oldName := ctx.PathParam("*")
repo := ctx.Repo.Repository

View File

@@ -90,7 +90,7 @@ type swaggerParameterBodies struct {
// in:body
EditRepoOption api.EditRepoOption
// in:body
UpdateBranchRepoOption api.UpdateBranchRepoOption
RenameBranchRepoOption api.RenameBranchRepoOption
// in:body
TransferRepoOption api.TransferRepoOption
// in:body