|
|
@@ -16,6 +16,7 @@ import (
|
|
|
"gopkg.in/macaron.v1"
|
|
|
)
|
|
|
|
|
|
+// CreateRepo holds CreateRepo
|
|
|
type CreateRepo struct {
|
|
|
UserID int64 `binding:"Required"`
|
|
|
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
|
|
|
@@ -27,21 +28,24 @@ type CreateRepo struct {
|
|
|
Readme string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *CreateRepo) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// MigrateRepo holds MigrateRepo
|
|
|
type MigrateRepo struct {
|
|
|
CloneAddr string `json:"clone_addr" binding:"Required"`
|
|
|
AuthUsername string `json:"auth_username"`
|
|
|
AuthPassword string `json:"auth_password"`
|
|
|
- Uid int64 `json:"uid" binding:"Required"`
|
|
|
+ UID int64 `json:"uid" binding:"Required"`
|
|
|
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
|
|
|
Mirror bool `json:"mirror"`
|
|
|
Private bool `json:"private"`
|
|
|
Description string `json:"description" binding:"MaxSize(512)"`
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *MigrateRepo) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
@@ -74,6 +78,7 @@ func (f MigrateRepo) ParseRemoteAddr(user *models.User) (string, error) {
|
|
|
return remoteAddr, nil
|
|
|
}
|
|
|
|
|
|
+// RepoSetting holds RepoSetting
|
|
|
type RepoSetting struct {
|
|
|
RepoName string `binding:"Required;AlphaDashDot;MaxSize(100)"`
|
|
|
Description string `binding:"MaxSize(512)"`
|
|
|
@@ -103,10 +108,12 @@ type RepoSetting struct {
|
|
|
PullsAllowRebase bool
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *RepoSetting) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// ProtectBranch holds ProtectBranch
|
|
|
type ProtectBranch struct {
|
|
|
Protected bool
|
|
|
RequirePullRequest bool
|
|
|
@@ -115,10 +122,12 @@ type ProtectBranch struct {
|
|
|
WhitelistTeams string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *ProtectBranch) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// Webhook holds Webhook
|
|
|
type Webhook struct {
|
|
|
Events string
|
|
|
Create bool
|
|
|
@@ -132,18 +141,22 @@ type Webhook struct {
|
|
|
Active bool
|
|
|
}
|
|
|
|
|
|
+// PushOnly returns push_only
|
|
|
func (f Webhook) PushOnly() bool {
|
|
|
return f.Events == "push_only"
|
|
|
}
|
|
|
|
|
|
+// SendEverything returns send_everything
|
|
|
func (f Webhook) SendEverything() bool {
|
|
|
return f.Events == "send_everything"
|
|
|
}
|
|
|
|
|
|
+// ChooseEvents returns choose_events
|
|
|
func (f Webhook) ChooseEvents() bool {
|
|
|
return f.Events == "choose_events"
|
|
|
}
|
|
|
|
|
|
+// NewWebhook holds NewWebhook
|
|
|
type NewWebhook struct {
|
|
|
PayloadURL string `binding:"Required;Url"`
|
|
|
ContentType int `binding:"Required"`
|
|
|
@@ -151,10 +164,12 @@ type NewWebhook struct {
|
|
|
Webhook
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *NewWebhook) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// NewSlackHook holds NewSlackHook
|
|
|
type NewSlackHook struct {
|
|
|
PayloadURL string `binding:"Required;Url"`
|
|
|
Channel string `binding:"Required"`
|
|
|
@@ -164,10 +179,12 @@ type NewSlackHook struct {
|
|
|
Webhook
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *NewSlackHook) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// NewDiscordHook holds NewDiscordHook
|
|
|
type NewDiscordHook struct {
|
|
|
PayloadURL string `binding:"Required;Url"`
|
|
|
Username string
|
|
|
@@ -176,10 +193,12 @@ type NewDiscordHook struct {
|
|
|
Webhook
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *NewDiscordHook) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// NewIssue holds NewIssue
|
|
|
type NewIssue struct {
|
|
|
Title string `binding:"Required;MaxSize(255)"`
|
|
|
LabelIDs string `form:"label_ids"`
|
|
|
@@ -189,48 +208,58 @@ type NewIssue struct {
|
|
|
Files []string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *NewIssue) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// CreateComment holds CreateComment
|
|
|
type CreateComment struct {
|
|
|
Content string
|
|
|
Status string `binding:"OmitEmpty;In(reopen,close)"`
|
|
|
Files []string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *CreateComment) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// CreateMilestone holds CreateMilestone
|
|
|
type CreateMilestone struct {
|
|
|
Title string `binding:"Required;MaxSize(50)"`
|
|
|
Content string
|
|
|
Deadline string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *CreateMilestone) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// CreateLabel holds CreateLabel
|
|
|
type CreateLabel struct {
|
|
|
ID int64
|
|
|
Title string `binding:"Required;MaxSize(50)" locale:"repo.issues.label_title"`
|
|
|
Color string `binding:"Required;Size(7)" locale:"repo.issues.label_color"`
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *CreateLabel) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// InitializeLabels holds InitializeLabels
|
|
|
type InitializeLabels struct {
|
|
|
TemplateName string `binding:"Required"`
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *InitializeLabels) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// NewRelease holds NewRelease
|
|
|
type NewRelease struct {
|
|
|
TagName string `binding:"Required"`
|
|
|
Target string `form:"tag_target" binding:"Required"`
|
|
|
@@ -241,10 +270,12 @@ type NewRelease struct {
|
|
|
Files []string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *NewRelease) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// EditRelease holds EditRelease
|
|
|
type EditRelease struct {
|
|
|
Title string `binding:"Required"`
|
|
|
Content string
|
|
|
@@ -253,10 +284,12 @@ type EditRelease struct {
|
|
|
Files []string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *EditRelease) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// NewWiki holds NewWiki
|
|
|
type NewWiki struct {
|
|
|
OldTitle string
|
|
|
Title string `binding:"Required"`
|
|
|
@@ -264,73 +297,87 @@ type NewWiki struct {
|
|
|
Message string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
// FIXME: use code generation to generate this method.
|
|
|
func (f *NewWiki) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// EditRepoFile holds EditRepoFile
|
|
|
type EditRepoFile struct {
|
|
|
TreePath string `binding:"Required;MaxSize(500)"`
|
|
|
Content string `binding:"Required"`
|
|
|
- CommitSummary string `binding:"MaxSize(100)`
|
|
|
+ CommitSummary string `binding:"MaxSize(100)"`
|
|
|
CommitMessage string
|
|
|
CommitChoice string `binding:"Required;MaxSize(50)"`
|
|
|
NewBranchName string `binding:"AlphaDashDotSlash;MaxSize(100)"`
|
|
|
LastCommit string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *EditRepoFile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
-func (f *EditRepoFile) IsNewBrnach() bool {
|
|
|
+// IsNewBranch returns commit-to-new-branch
|
|
|
+func (f *EditRepoFile) IsNewBranch() bool {
|
|
|
return f.CommitChoice == "commit-to-new-branch"
|
|
|
}
|
|
|
|
|
|
+// EditPreviewDiff holds EditPreviewDiff
|
|
|
type EditPreviewDiff struct {
|
|
|
Content string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *EditPreviewDiff) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// UploadRepoFile holds UploadRepoFile
|
|
|
type UploadRepoFile struct {
|
|
|
- TreePath string `binding:MaxSize(500)"`
|
|
|
- CommitSummary string `binding:"MaxSize(100)`
|
|
|
+ TreePath string `binding:"MaxSize(500)"`
|
|
|
+ CommitSummary string `binding:"MaxSize(100)"`
|
|
|
CommitMessage string
|
|
|
CommitChoice string `binding:"Required;MaxSize(50)"`
|
|
|
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
|
|
Files []string
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *UploadRepoFile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
-func (f *UploadRepoFile) IsNewBrnach() bool {
|
|
|
+// IsNewBranch returns commit-to-new-branch
|
|
|
+func (f *UploadRepoFile) IsNewBranch() bool {
|
|
|
return f.CommitChoice == "commit-to-new-branch"
|
|
|
}
|
|
|
|
|
|
+// RemoveUploadFile holds RemoveUploadFile
|
|
|
type RemoveUploadFile struct {
|
|
|
File string `binding:"Required;MaxSize(50)"`
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *RemoveUploadFile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
+// DeleteRepoFile holds DeleteRepoFile
|
|
|
type DeleteRepoFile struct {
|
|
|
- CommitSummary string `binding:"MaxSize(100)`
|
|
|
+ CommitSummary string `binding:"MaxSize(100)"`
|
|
|
CommitMessage string
|
|
|
CommitChoice string `binding:"Required;MaxSize(50)"`
|
|
|
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
|
|
}
|
|
|
|
|
|
+// Validate validates fields
|
|
|
func (f *DeleteRepoFile) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
|
|
return validate(errs, ctx.Data, f, ctx.Locale)
|
|
|
}
|
|
|
|
|
|
-func (f *DeleteRepoFile) IsNewBrnach() bool {
|
|
|
+// IsNewBranch returns commit-to-new-branch
|
|
|
+func (f *DeleteRepoFile) IsNewBranch() bool {
|
|
|
return f.CommitChoice == "commit-to-new-branch"
|
|
|
}
|