From dccb0c15b996ac4dc0307cbfed140ce1558d7e3c Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 14 Aug 2016 04:17:26 -0700 Subject: Replace convert.To with APIFormat calls --- routers/api/v1/repo/repo.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'routers/api/v1/repo/repo.go') diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index e1c1b576..cc75f5bf 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -93,12 +93,12 @@ func ListMyRepos(ctx *context.APIContext) { repos := make([]*api.Repository, numOwnRepos+len(accessibleRepos)) for i := range ownRepos { - repos[i] = convert.ToRepository(ctx.User, ownRepos[i], api.Permission{true, true, true}) + repos[i] = ownRepos[i].APIFormat(&api.Permission{true, true, true}) } i := numOwnRepos for repo, access := range accessibleRepos { - repos[i] = convert.ToRepository(repo.Owner, repo, api.Permission{ + repos[i] = repo.APIFormat(&api.Permission{ Admin: access >= models.ACCESS_MODE_ADMIN, Push: access >= models.ACCESS_MODE_WRITE, Pull: true, @@ -135,7 +135,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR return } - ctx.JSON(201, convert.ToRepository(owner, repo, api.Permission{true, true, true})) + ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true})) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#create @@ -235,7 +235,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { } log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) - ctx.JSON(201, convert.ToRepository(ctxUser, repo, api.Permission{true, true, true})) + ctx.JSON(201, repo.APIFormat(&api.Permission{true, true, true})) } func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repository) { @@ -264,12 +264,12 @@ func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repositor // https://github.com/gogits/go-gogs-client/wiki/Repositories#get func Get(ctx *context.APIContext) { - owner, repo := parseOwnerAndRepo(ctx) + _, repo := parseOwnerAndRepo(ctx) if ctx.Written() { return } - ctx.JSON(200, convert.ToRepository(owner, repo, api.Permission{true, true, true})) + ctx.JSON(200, repo.APIFormat(&api.Permission{true, true, true})) } // https://github.com/gogits/go-gogs-client/wiki/Repositories#delete -- cgit v1.2.3