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