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