MCPcopy Create free account
hub / github.com/gogs/gogs / GetUserAndCollaborativeRepositories

Function GetUserAndCollaborativeRepositories

internal/database/repo.go:1848–1863  ·  view source on GitHub ↗

GetUserAndCollaborativeRepositories returns list of repositories the user owns and collaborates.

(userID int64)

Source from the content-addressed store, hash-verified

1846
1847// GetUserAndCollaborativeRepositories returns list of repositories the user owns and collaborates.
1848func GetUserAndCollaborativeRepositories(userID int64) ([]*Repository, error) {
1849 repos := make([]*Repository, 0, 10)
1850 if err := x.Alias("repo").
1851 Join("INNER", "collaboration", "collaboration.repo_id = repo.id").
1852 Where("collaboration.user_id = ?", userID).
1853 Find(&repos); err != nil {
1854 return nil, errors.Newf("select collaborative repositories: %v", err)
1855 }
1856
1857 ownRepos := make([]*Repository, 0, 10)
1858 if err := x.Where("owner_id = ?", userID).Find(&ownRepos); err != nil {
1859 return nil, errors.Newf("select own repositories: %v", err)
1860 }
1861
1862 return append(repos, ownRepos...), nil
1863}
1864
1865type SearchRepoOptions struct {
1866 Keyword string

Callers 1

SettingsReposFunction · 0.92

Calls 3

appendFunction · 0.85
WhereMethod · 0.80
FindMethod · 0.65

Tested by

no test coverage detected