MCPcopy Create free account
hub / github.com/gogs/gogs / parseBaseRepository

Function parseBaseRepository

internal/route/repo/pull.go:45–82  ·  view source on GitHub ↗
(c *context.Context)

Source from the content-addressed store, hash-verified

43)
44
45func 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
84func Fork(c *context.Context) {
85 c.Data["Title"] = c.Tr("new_fork")

Callers 2

ForkFunction · 0.85
ForkPostFunction · 0.85

Calls 9

GetRepositoryByIDFunction · 0.92
CanBeForkedMethod · 0.80
GetOwnerMethod · 0.80
OrganizationsMethod · 0.80
NotFoundMethod · 0.65
ListMethod · 0.65
NotFoundOrErrorMethod · 0.45
HasAccessMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected