Browse Source

api/repo: load attributes when listing user repositories (#4565)

pull/4584/head
Unknwon 8 years ago
parent
commit
11b1498a6e
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 2
      gogs.go
  2. 6
      models/access.go
  3. 2
      models/repo.go
  4. 6
      routes/api/v1/repo/repo.go
  5. 2
      templates/.VERSION

2
gogs.go

@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/pkg/setting"
)
const APP_VER = "0.11.21.0611"
const APP_VER = "0.11.22.0621"
func init() {
setting.AppVer = APP_VER

6
models/access.go

@ -112,14 +112,12 @@ func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) {
repo, err := GetRepositoryByID(access.RepoID)
if err != nil {
if errors.IsRepoNotExist(err) {
log.Error(4, "GetRepositoryByID: %v", err)
log.Error(2, "GetRepositoryByID: %v", err)
continue
}
return nil, err
}
if err = repo.GetOwner(); err != nil {
return nil, err
} else if repo.OwnerID == u.ID {
if repo.OwnerID == u.ID {
continue
}
repos[repo] = access.Mode

2
models/repo.go

@ -282,6 +282,8 @@ func (repo *Repository) HTMLURL() string {
return setting.AppURL + repo.FullName()
}
// This method assumes following fields have been assigned with valid values:
// Required - BaseRepo (if fork)
// Arguments that are allowed to be nil: permission
func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
cloneLink := repo.CloneLink()

6
routes/api/v1/repo/repo.go

@ -101,6 +101,12 @@ func listUserRepositories(c *context.APIContext, username string) {
return
}
if err = models.RepositoryList(ownRepos).LoadAttributes(); err != nil {
c.Error(500, "LoadAttributes(ownRepos)", err)
return
}
// Early return for querying other user's repositories
if c.User.ID != user.ID {
repos := make([]*api.Repository, len(ownRepos))
for i := range ownRepos {

2
templates/.VERSION

@ -1 +1 @@
0.11.21.0611
0.11.22.0621
Loading…
Cancel
Save