aboutsummaryrefslogtreecommitdiffstats
path: root/services/forms/repo_form_editor.go
blob: 3ad2eae75dcdffc5027fc597197cba5b142a5f40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package forms

import (
	"net/http"

	"code.gitea.io/gitea/modules/optional"
	"code.gitea.io/gitea/modules/web/middleware"
	"code.gitea.io/gitea/services/context"

	"gitea.com/go-chi/binding"
)

type CommitCommonForm struct {
	TreePath      string `binding:"MaxSize(500)"`
	CommitSummary string `binding:"MaxSize(100)"`
	CommitMessage string
	CommitChoice  string `binding:"Required;MaxSize(50)"`
	NewBranchName string `binding:"GitRefName;MaxSize(100)"`
	LastCommit    string
	Signoff       bool
	CommitEmail   string
}

func (f *CommitCommonForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
	ctx := context.GetValidateContext(req)
	return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
}

type CommitCommonFormInterface interface {
	GetCommitCommonForm() *CommitCommonForm
}

func (f *CommitCommonForm) GetCommitCommonForm() *CommitCommonForm {
	return f
}

type EditRepoFileForm struct {
	CommitCommonForm
	Content optional.Option[string]
}

type DeleteRepoFileForm struct {
	CommitCommonForm
}

type UploadRepoFileForm struct {
	CommitCommonForm
	Files []string
}

type CherryPickForm struct {
	CommitCommonForm
	Revert bool
}