瀏覽代碼

[api] Deep forking should be possible

With forks deeper then 1 (meaning forks of forks) the api breaks as it will
recursively ask for parents which in turn have not been fetched from the db.

Limiting the depth of the parent retrieval works around this.
cgars 7 年之前
父節點
當前提交
9f57801ab7
共有 1 個文件被更改,包括 3 次插入7 次删除
  1. 3 7
      models/repo.go

+ 3 - 7
models/repo.go

@@ -383,13 +383,9 @@ func (repo *Repository) APIFormat(permission *api.Permission, user ...*User) *ap
 		// Reserved for go-gogs-client change
 		//		AvatarUrl:     repo.AvatarLink(),
 	}
-	if repo.IsFork {
-		p := &api.Permission{Pull: true}
-		if len(user) != 0 {
-			p.Admin = user[0].IsAdminOfRepo(repo)
-			p.Push = user[0].IsWriterOfRepo(repo)
-		}
-		apiRepo.Parent = repo.BaseRepo.APIFormat(p)
+	if repo.IsFork && repo.BaseRepo != nil {
+		// FIXME: check precise permission for base repository
+		apiRepo.Parent = repo.BaseRepo.APIFormat(nil)
 	}
 	return apiRepo
 }