summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-11-13 02:32:18 -0500
committerUnknwon <joe2010xtmf@163.com>2014-11-13 02:32:18 -0500
commit8eb5120fbd19dac1221f82d84c339b4be9b0975b (patch)
tree3238704d9968d41f3f871adda4c280e3bd73685d /models/repo.go
parent8c9338a5377c60c84cdee1f5781b3de5933bb3b0 (diff)
downloadgitea-8eb5120fbd19dac1221f82d84c339b4be9b0975b.tar.gz
gitea-8eb5120fbd19dac1221f82d84c339b4be9b0975b.zip
#12, API: list user repos, list repo hooks
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/models/repo.go b/models/repo.go
index 1dbda2a006..d0cd1b553d 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1080,15 +1080,21 @@ func GetCollaboratorNames(repoName string) ([]string, error) {
return names, nil
}
+// CollaborativeRepository represents a repository with collaborative information.
+type CollaborativeRepository struct {
+ *Repository
+ CanPush bool
+}
+
// GetCollaborativeRepos returns a list of repositories that user is collaborator.
-func GetCollaborativeRepos(uname string) ([]*Repository, error) {
+func GetCollaborativeRepos(uname string) ([]*CollaborativeRepository, error) {
uname = strings.ToLower(uname)
accesses := make([]*Access, 0, 10)
if err := x.Find(&accesses, &Access{UserName: uname}); err != nil {
return nil, err
}
- repos := make([]*Repository, 0, 10)
+ repos := make([]*CollaborativeRepository, 0, 10)
for _, access := range accesses {
infos := strings.Split(access.RepoName, "/")
if infos[0] == uname {
@@ -1105,7 +1111,7 @@ func GetCollaborativeRepos(uname string) ([]*Repository, error) {
return nil, err
}
repo.Owner = u
- repos = append(repos, repo)
+ repos = append(repos, &CollaborativeRepository{repo, access.Mode == WRITABLE})
}
return repos, nil
}