Преглед изворни кода

[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
 }