Browse Source

repo: expose more fields to API format (#4484)

pull/3095/merge
Unknwon 8 years ago
parent
commit
c69fa18434
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 9
      models/repo.go

9
models/repo.go

@ -285,7 +285,7 @@ func (repo *Repository) HTMLURL() string {
// Arguments that are allowed to be nil: permission // Arguments that are allowed to be nil: permission
func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository { func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
cloneLink := repo.CloneLink() cloneLink := repo.CloneLink()
return &api.Repository{ apiRepo := &api.Repository{
ID: repo.ID, ID: repo.ID,
Owner: repo.Owner.APIFormat(), Owner: repo.Owner.APIFormat(),
Name: repo.Name, Name: repo.Name,
@ -293,7 +293,9 @@ func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
Description: repo.Description, Description: repo.Description,
Private: repo.IsPrivate, Private: repo.IsPrivate,
Fork: repo.IsFork, Fork: repo.IsFork,
Empty: repo.IsBare,
Mirror: repo.IsMirror, Mirror: repo.IsMirror,
Size: repo.Size,
HTMLURL: repo.HTMLURL(), HTMLURL: repo.HTMLURL(),
SSHURL: cloneLink.SSH, SSHURL: cloneLink.SSH,
CloneURL: cloneLink.HTTPS, CloneURL: cloneLink.HTTPS,
@ -307,6 +309,11 @@ func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
Updated: repo.Updated, Updated: repo.Updated,
Permissions: permission, 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) { func (repo *Repository) getOwner(e Engine) (err error) {

Loading…
Cancel
Save