소스 검색

[api] Repos search api should not need query

and rather return all public repositories .
also removed the html clone link and email addresses from api format
cgars 7 년 전
부모
커밋
4fdaf5c932
3개의 변경된 파일6개의 추가작업 그리고 5개의 파일을 삭제
  1. 0 1
      models/repo.go
  2. 0 1
      models/user.go
  3. 6 3
      routes/api/v1/repo/repo.go

+ 0 - 1
models/repo.go

@@ -370,7 +370,6 @@ func (repo *Repository) APIFormat(permission *api.Permission, user ...*User) *ap
 		Size:          repo.Size,
 		HTMLURL:       repo.HTMLURL(),
 		SSHURL:        cloneLink.SSH,
-		CloneURL:      cloneLink.HTTPS,
 		Website:       repo.Website,
 		Stars:         repo.NumStars,
 		Forks:         repo.NumForks,

+ 0 - 1
models/user.go

@@ -135,7 +135,6 @@ func (u *User) APIFormat() *api.User {
 		UserName:  u.Name,
 		Login:     u.Name,
 		FullName:  u.FullName,
-		Email:     u.Email,
 		AvatarUrl: u.AvatarLink(),
 	}
 }

+ 6 - 3
routes/api/v1/repo/repo.go

@@ -29,9 +29,8 @@ func Search(c *context.APIContext) {
 	}
 
 	// workaround for the all querry with logged users
-	if opts.Keyword == "." && c.User.ID > 0 {
+	if opts.Keyword == "." {
 		opts.Keyword = ""
-		log.Trace("User %i asked for all repos")
 	}
 	// Check visibility.
 	if c.IsLogged && opts.OwnerID > 0 {
@@ -72,7 +71,11 @@ func Search(c *context.APIContext) {
 
 	results := make([]*api.Repository, len(repos))
 	for i := range repos {
-		results[i] = repos[i].APIFormat(nil)
+		rep := repos[i].APIFormat(nil)
+		if ! c.IsLogged {
+			rep.Owner.Email = ""
+		}
+		results[i] = rep
 	}
 
 	c.SetLinkHeader(int(count), opts.PageSize)