Преглед на файлове

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