|
8 | 8 | "time" |
9 | 9 |
|
10 | 10 | activities_model "code.gitea.io/gitea/models/activities" |
| 11 | + "code.gitea.io/gitea/models/git" |
11 | 12 | "code.gitea.io/gitea/models/unit" |
12 | 13 | "code.gitea.io/gitea/modules/base" |
13 | 14 | "code.gitea.io/gitea/services/context" |
@@ -52,12 +53,26 @@ func Activity(ctx *context.Context) { |
52 | 53 | ctx.Data["DateUntil"] = timeUntil |
53 | 54 | ctx.Data["PeriodText"] = ctx.Tr("repo.activity.period." + ctx.Data["Period"].(string)) |
54 | 55 |
|
| 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 | + } |
| 65 | + } |
| 66 | + |
55 | 67 | var err error |
56 | | - 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, |
57 | 70 | ctx.Repo.CanRead(unit.TypeReleases), |
58 | 71 | ctx.Repo.CanRead(unit.TypeIssues), |
59 | 72 | ctx.Repo.CanRead(unit.TypePullRequests), |
60 | | - ctx.Repo.CanRead(unit.TypeCode)); err != nil { |
| 73 | + canReadCode, |
| 74 | + ) |
| 75 | + if err != nil { |
61 | 76 | ctx.ServerError("GetActivityStats", err) |
62 | 77 | return |
63 | 78 | } |
|
0 commit comments