#2780 code clean up

release/v1.15
Unknwon 2016-08-11 11:35:46 -07:00
parent b6c14f8b21
commit 7e9b42c87d
5 changed files with 13 additions and 21 deletions

View File

@ -19,7 +19,7 @@ github.com/go-xorm/xorm = commit:c6c7056
github.com/gogits/chardet = commit:2404f77
github.com/gogits/cron = commit:7f3990a
github.com/gogits/git-module = commit:efc90b5
github.com/gogits/go-gogs-client = commit:d1020b4
github.com/gogits/go-gogs-client = commit:1fef67c
github.com/issue9/identicon = commit:d36b545
github.com/jaytaylor/html2text = commit:52d9b78
github.com/kardianos/minwinsvc = commit:cad6b2b

View File

@ -88,7 +88,7 @@ func checkVersion() {
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
{"gopkg.in/macaron.v1", macaron.Version, "1.1.7"},
{"github.com/gogits/git-module", git.Version, "0.3.5"},
{"github.com/gogits/go-gogs-client", gogs.Version, "0.10.3"},
{"github.com/gogits/go-gogs-client", gogs.Version, "0.10.4"},
}
for _, c := range checkers {
if !version.Compare(c.Version(), c.Expected, ">=") {

2
glide.lock generated
View File

@ -43,7 +43,7 @@ imports:
- name: github.com/gogits/git-module
version: efc90b5ea1f7b7e404673dcc19674b2a6856e0d3
- name: github.com/gogits/go-gogs-client
version: d1020b4da5474f7533f5b11084dcfd5536cf2e71
version: 1fef67c1910680405ebb3a2f1aecce35e1575b4d
- name: github.com/issue9/identicon
version: d36b54562f4cf70c83653e13dc95c220c79ef521
- name: github.com/jaytaylor/html2text

View File

@ -29,7 +29,7 @@ func (c *Collaboration) ModeI18nKey() string {
}
}
// AddCollaborator adds new collaboration relation between an individual and a repository.
// AddCollaborator adds new collaboration to a repository with default access mode.
func (repo *Repository) AddCollaborator(u *User) error {
collaboration := &Collaboration{
RepoID: repo.ID,
@ -120,6 +120,9 @@ func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode
return nil
}
if collaboration.Mode == mode {
return nil
}
collaboration.Mode = mode
sess := x.NewSession()

View File

@ -1,4 +1,4 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
@ -13,7 +13,6 @@ import (
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
collaborator, err := models.GetUserByName(ctx.Params(":collaborator"))
if err != nil {
if models.IsErrUserNotExist(err) {
ctx.Error(422, "", err)
@ -28,22 +27,12 @@ func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
return
}
mode := models.ACCESS_MODE_WRITE
if form.Permission != nil && *form.Permission == "pull" {
mode = models.ACCESS_MODE_READ
} else if form.Permission != nil && *form.Permission == "push" {
mode = models.ACCESS_MODE_WRITE
} else if form.Permission != nil && *form.Permission == "admin" {
mode = models.ACCESS_MODE_ADMIN
} else if form.Permission != nil {
ctx.Error(500, "Permission", "Invalid permission type")
return
}
if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(collaborator.Id, mode); err != nil {
if form.Permission != nil {
if err := ctx.Repo.Repository.ChangeCollaborationAccessMode(collaborator.ID, models.ParseAccessMode(*form.Permission)); err != nil {
ctx.Error(500, "ChangeCollaborationAccessMode", err)
return
}
}
ctx.Status(204)
return
}