You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo_branch_form.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package forms
  4. import (
  5. "net/http"
  6. "code.gitea.io/gitea/modules/context"
  7. "code.gitea.io/gitea/modules/web/middleware"
  8. "gitea.com/go-chi/binding"
  9. )
  10. // NewBranchForm form for creating a new branch
  11. type NewBranchForm struct {
  12. NewBranchName string `binding:"Required;MaxSize(100);GitRefName"`
  13. CurrentPath string
  14. CreateTag bool
  15. }
  16. // Validate validates the fields
  17. func (f *NewBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  18. ctx := context.GetValidateContext(req)
  19. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  20. }
  21. // RenameBranchForm form for rename a branch
  22. type RenameBranchForm struct {
  23. From string `binding:"Required;MaxSize(100);GitRefName"`
  24. To string `binding:"Required;MaxSize(100);GitRefName"`
  25. }
  26. // Validate validates the fields
  27. func (f *RenameBranchForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  28. ctx := context.GetValidateContext(req)
  29. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  30. }