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