gitea源码

repo_form_editor.go 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2025 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/optional"
  7. "code.gitea.io/gitea/modules/web/middleware"
  8. "code.gitea.io/gitea/services/context"
  9. "gitea.com/go-chi/binding"
  10. )
  11. type CommitCommonForm struct {
  12. TreePath string `binding:"MaxSize(500)"`
  13. CommitSummary string `binding:"MaxSize(100)"`
  14. CommitMessage string
  15. CommitChoice string `binding:"Required;MaxSize(50)"`
  16. NewBranchName string `binding:"GitRefName;MaxSize(100)"`
  17. LastCommit string
  18. Signoff bool
  19. CommitEmail string
  20. }
  21. func (f *CommitCommonForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  22. ctx := context.GetValidateContext(req)
  23. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  24. }
  25. type CommitCommonFormInterface interface {
  26. GetCommitCommonForm() *CommitCommonForm
  27. }
  28. func (f *CommitCommonForm) GetCommitCommonForm() *CommitCommonForm {
  29. return f
  30. }
  31. type EditRepoFileForm struct {
  32. CommitCommonForm
  33. Content optional.Option[string]
  34. }
  35. type DeleteRepoFileForm struct {
  36. CommitCommonForm
  37. }
  38. type UploadRepoFileForm struct {
  39. CommitCommonForm
  40. Files []string
  41. }
  42. type CherryPickForm struct {
  43. CommitCommonForm
  44. Revert bool
  45. }