@@ -53,18 +53,26 @@ func Activity(ctx *context.Context) {
5353 ctx .Data ["DateUntil" ] = timeUntil
5454 ctx .Data ["PeriodText" ] = ctx .Tr ("repo.activity.period." + ctx .Data ["Period" ].(string ))
5555
56- branchExist , _ := git .IsBranchExist (ctx , ctx .Repo .Repository .ID , ctx .Repo .Repository .DefaultBranch )
57- if ! branchExist {
58- ctx .Data ["NotFoundPrompt" ] = ctx .Tr ("repo.branch.default_branch_not_exist" , ctx .Repo .Repository .DefaultBranch )
59- ctx .NotFound (nil )
60- return
56+ canReadCode := ctx .Repo .CanRead (unit .TypeCode )
57+ if canReadCode {
58+ // GetActivityStats needs to read the default branch to get some information
59+ branchExist , _ := git .IsBranchExist (ctx , ctx .Repo .Repository .ID , ctx .Repo .Repository .DefaultBranch )
60+ if ! branchExist {
61+ ctx .Data ["NotFoundPrompt" ] = ctx .Tr ("repo.branch.default_branch_not_exist" , ctx .Repo .Repository .DefaultBranch )
62+ ctx .NotFound (nil )
63+ return
64+ }
6165 }
66+
6267 var err error
63- if ctx .Data ["Activity" ], err = activities_model .GetActivityStats (ctx , ctx .Repo .Repository , timeFrom ,
68+ // TODO: refactor these arguments to a struct
69+ ctx .Data ["Activity" ], err = activities_model .GetActivityStats (ctx , ctx .Repo .Repository , timeFrom ,
6470 ctx .Repo .CanRead (unit .TypeReleases ),
6571 ctx .Repo .CanRead (unit .TypeIssues ),
6672 ctx .Repo .CanRead (unit .TypePullRequests ),
67- ctx .Repo .CanRead (unit .TypeCode )); err != nil {
73+ canReadCode ,
74+ )
75+ if err != nil {
6876 ctx .ServerError ("GetActivityStats" , err )
6977 return
7078 }
0 commit comments