mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	API: support /users/:username/repos
clean up fix arguments remove repeated token give admins listing rights
This commit is contained in:
		
				
					committed by
					
						
						Kim "BKC" Carlbäcker
					
				
			
			
				
	
			
			
			
						parent
						
							9084bdd863
						
					
				
				
					commit
					c0f99e8229
				
			@@ -81,36 +81,6 @@ func Search(ctx *context.APIContext) {
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ListMyRepos list all my repositories
 | 
			
		||||
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories
 | 
			
		||||
func ListMyRepos(ctx *context.APIContext) {
 | 
			
		||||
	ownRepos, err := models.GetUserRepositories(ctx.User.ID, true, 1, ctx.User.NumRepos, "")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		ctx.Error(500, "GetRepositories", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	numOwnRepos := len(ownRepos)
 | 
			
		||||
 | 
			
		||||
	accessibleRepos, err := ctx.User.GetRepositoryAccesses()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		ctx.Error(500, "GetRepositoryAccesses", err)
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	repos := make([]*api.Repository, numOwnRepos+len(accessibleRepos))
 | 
			
		||||
	for i := range ownRepos {
 | 
			
		||||
		repos[i] = ownRepos[i].APIFormat(models.AccessModeOwner)
 | 
			
		||||
	}
 | 
			
		||||
	i := numOwnRepos
 | 
			
		||||
 | 
			
		||||
	for repo, access := range accessibleRepos {
 | 
			
		||||
		repos[i] = repo.APIFormat(access)
 | 
			
		||||
		i++
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ctx.JSON(200, &repos)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateUserRepo create a repository for a user
 | 
			
		||||
func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateRepoOption) {
 | 
			
		||||
	repo, err := models.CreateRepository(owner, models.CreateRepoOptions{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user