From c69fa18434f9377557cb3e417d5469e0740e48d1 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 2 Jun 2017 14:26:34 -0400 Subject: [PATCH] repo: expose more fields to API format (#4484) --- models/repo.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/models/repo.go b/models/repo.go index 0aa6afda8..873546411 100644 --- a/models/repo.go +++ b/models/repo.go @@ -285,7 +285,7 @@ func (repo *Repository) HTMLURL() string { // Arguments that are allowed to be nil: permission func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository { cloneLink := repo.CloneLink() - return &api.Repository{ + apiRepo := &api.Repository{ ID: repo.ID, Owner: repo.Owner.APIFormat(), Name: repo.Name, @@ -293,7 +293,9 @@ func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository { Description: repo.Description, Private: repo.IsPrivate, Fork: repo.IsFork, + Empty: repo.IsBare, Mirror: repo.IsMirror, + Size: repo.Size, HTMLURL: repo.HTMLURL(), SSHURL: cloneLink.SSH, CloneURL: cloneLink.HTTPS, @@ -307,6 +309,11 @@ func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository { Updated: repo.Updated, Permissions: permission, } + if repo.IsFork { + // FIXME: check precise permission for base repository + apiRepo.Parent = repo.BaseRepo.APIFormat(nil) + } + return apiRepo } func (repo *Repository) getOwner(e Engine) (err error) {