2017-10-15 14:59:24 -05:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2021-01-26 09:36:53 -06:00
|
|
|
package forms
|
2017-10-15 14:59:24 -05:00
|
|
|
|
|
|
|
import (
|
2021-01-26 09:36:53 -06:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/context"
|
2021-01-30 02:55:53 -06:00
|
|
|
"code.gitea.io/gitea/modules/web/middleware"
|
2021-01-26 09:36:53 -06: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"`
|
2021-02-28 13:57:45 -06:00
|
|
|
CreateTag bool
|
2017-10-15 14:59:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Validate validates the fields
|
2021-01-26 09:36:53 -06:00
|
|
|
func (f *NewBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
|
|
|
ctx := context.GetContext(req)
|
2021-01-30 02:55:53 -06:00
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
2017-10-15 14:59:24 -05:00
|
|
|
}
|