aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-24 15:34:02 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-24 15:34:02 -0400
commit87854c95a90cf1bebe1bffb833389471fb35f234 (patch)
tree95888810bd31f3fb99e16c646777636df96f950b
parent80055bde86c21f1245a7b45ba30406db7640fec0 (diff)
downloadgitea-87854c95a90cf1bebe1bffb833389471fb35f234.tar.gz
gitea-87854c95a90cf1bebe1bffb833389471fb35f234.zip
Fixed #200
-rw-r--r--models/issue.go4
-rw-r--r--routers/repo/issue.go10
2 files changed, 13 insertions, 1 deletions
diff --git a/models/issue.go b/models/issue.go
index d0a65298b2..18057985f0 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -473,6 +473,10 @@ func NewLabel(l *Label) error {
// GetLabelById returns a label by given ID.
func GetLabelById(id int64) (*Label, error) {
+ if id <= 0 {
+ return nil, ErrLabelNotExist
+ }
+
l := &Label{Id: id}
has, err := orm.Get(l)
if err != nil {
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 23f2480dda..6e04288c2b 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -742,7 +742,15 @@ func UpdateLabel(ctx *middleware.Context, params martini.Params, form auth.Creat
}
func DeleteLabel(ctx *middleware.Context) {
- strIds := strings.Split(ctx.Query("remove"), ",")
+ removes := ctx.Query("remove")
+ if len(strings.TrimSpace(removes)) == 0 {
+ ctx.JSON(200, map[string]interface{}{
+ "ok": true,
+ })
+ return
+ }
+
+ strIds := strings.Split(removes, ",")
for _, strId := range strIds {
if err := models.DeleteLabel(ctx.Repo.Repository.Id, strId); err != nil {
ctx.Handle(500, "issue.DeleteLabel(DeleteLabel)", err)