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