(c *context.Context)
| 43 | ) |
| 44 | |
| 45 | func parseBaseRepository(c *context.Context) *database.Repository { |
| 46 | baseRepo, err := database.GetRepositoryByID(c.ParamsInt64(":repoid")) |
| 47 | if err != nil { |
| 48 | c.NotFoundOrError(err, "get repository by ID") |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | if !baseRepo.CanBeForked() || !baseRepo.HasAccess(c.User.ID) { |
| 53 | c.NotFound() |
| 54 | return nil |
| 55 | } |
| 56 | |
| 57 | c.Data["repo_name"] = baseRepo.Name |
| 58 | c.Data["description"] = baseRepo.Description |
| 59 | c.Data["IsPrivate"] = baseRepo.IsPrivate |
| 60 | c.Data["IsUnlisted"] = baseRepo.IsUnlisted |
| 61 | |
| 62 | if err = baseRepo.GetOwner(); err != nil { |
| 63 | c.Error(err, "get owner") |
| 64 | return nil |
| 65 | } |
| 66 | c.Data["ForkFrom"] = baseRepo.Owner.Name + "/" + baseRepo.Name |
| 67 | |
| 68 | orgs, err := database.Handle.Organizations().List( |
| 69 | c.Req.Context(), |
| 70 | database.ListOrgsOptions{ |
| 71 | MemberID: c.User.ID, |
| 72 | IncludePrivateMembers: true, |
| 73 | }, |
| 74 | ) |
| 75 | if err != nil { |
| 76 | c.Error(err, "list organizations") |
| 77 | return nil |
| 78 | } |
| 79 | c.Data["Orgs"] = orgs |
| 80 | |
| 81 | return baseRepo |
| 82 | } |
| 83 | |
| 84 | func Fork(c *context.Context) { |
| 85 | c.Data["Title"] = c.Tr("new_fork") |
no test coverage detected