Browse Source

#981

add tag-size limit when submit
tags/v1.21.12.2^2
chenyifan01 4 years ago
parent
commit
7f62981efb
2 changed files with 6 additions and 2 deletions
  1. +0
    -2
      models/repo_tag.go
  2. +6
    -0
      routers/org/tag.go

+ 0
- 2
models/repo_tag.go View File

@@ -6,8 +6,6 @@ import (
"fmt"
)

const DefaultOrgTagLimit = -1

type OfficialTag struct {
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"NOT NULL"`


+ 6
- 0
routers/org/tag.go View File

@@ -13,6 +13,8 @@ import (
"strconv"
)

const DefaultOrgTagLimit = -1

// SubmitTags submit repos of org tag
func SubmitTags(ctx *context.Context, form auth.SubmitReposOfTagForm) {
if !ctx.Org.IsOwner {
@@ -23,6 +25,10 @@ func SubmitTags(ctx *context.Context, form auth.SubmitReposOfTagForm) {
if ctx.Written() {
return
}
if tag.Limit != DefaultOrgTagLimit && len(form.RepoList) > tag.Limit {
ctx.ServerError("UpdateTagReposByID", errors.New("tags size over limit"))
return
}
err := models.UpdateTagReposByID(tag.ID, ctx.Org.Organization.ID, form.RepoList)
if err != nil {
ctx.ServerError("UpdateTagReposByID", err)


Loading…
Cancel
Save