2017-10-16 03:59:24 +08:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-28 02:20:29 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-10-16 03:59:24 +08:00
|
|
|
|
2021-01-26 23:36:53 +08:00
|
|
|
package forms
|
2017-10-16 03:59:24 +08:00
|
|
|
|
|
|
|
import (
|
2021-01-26 23:36:53 +08:00
|
|
|
"net/http"
|
|
|
|
|
2021-01-30 16:55:53 +08:00
|
|
|
"code.gitea.io/gitea/modules/web/middleware"
|
2024-02-27 15:12:22 +08:00
|
|
|
"code.gitea.io/gitea/services/context"
|
2021-01-26 23:36:53 +08:00
|
|
|
|
|
|
|
"gitea.com/go-chi/binding"
|
2017-10-16 03:59:24 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// NewBranchForm form for creating a new branch
|
|
|
|
type NewBranchForm struct {
|
|
|
|
NewBranchName string `binding:"Required;MaxSize(100);GitRefName"`
|
2022-09-15 21:25:16 +08:00
|
|
|
CurrentPath string
|
2021-03-01 03:57:45 +08:00
|
|
|
CreateTag bool
|
2017-10-16 03:59:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Validate validates the fields
|
2021-01-26 23:36:53 +08:00
|
|
|
func (f *NewBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
2023-05-21 09:50:53 +08:00
|
|
|
ctx := context.GetValidateContext(req)
|
2021-01-30 16:55:53 +08:00
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
2017-10-16 03:59:24 +08:00
|
|
|
}
|
2021-10-09 01:03:04 +08:00
|
|
|
|
|
|
|
// RenameBranchForm form for rename a branch
|
|
|
|
type RenameBranchForm struct {
|
|
|
|
From string `binding:"Required;MaxSize(100);GitRefName"`
|
|
|
|
To string `binding:"Required;MaxSize(100);GitRefName"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate validates the fields
|
|
|
|
func (f *RenameBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
2023-05-21 09:50:53 +08:00
|
|
|
ctx := context.GetValidateContext(req)
|
2021-10-09 01:03:04 +08:00
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
|
}
|