Explorar el Código

[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 hace 7 años
padre
commit
97ddceee30
Se han modificado 3 ficheros con 6 adiciones y 5 borrados
  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

@@ -300,7 +300,6 @@ func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
 		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

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

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

@@ -28,9 +28,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 {
@@ -71,7 +70,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), setting.API.MaxResponseItems)