Skip to content

Commit 08b15e5

Browse files
committed
fix
1 parent 88352e0 commit 08b15e5

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,7 @@ branch.restore_success = Branch "%s" has been restored.
27332733
branch.restore_failed = Failed to restore branch "%s".
27342734
branch.protected_deletion_failed = Branch "%s" is protected. It cannot be deleted.
27352735
branch.default_deletion_failed = Branch "%s" is the default branch. It cannot be deleted.
2736+
branch.default_branch_not_exist = Default branch "%s" does not exist.
27362737
branch.restore = Restore Branch "%s"
27372738
branch.download = Download Branch "%s"
27382739
branch.rename = Rename Branch "%s"

routers/web/repo/actions/actions.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package actions
66
import (
77
"bytes"
88
stdCtx "context"
9+
"errors"
910
"net/http"
1011
"slices"
1112
"strings"
@@ -67,7 +68,11 @@ func List(ctx *context.Context) {
6768
ctx.Data["PageIsActions"] = true
6869

6970
commit, err := ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
70-
if err != nil {
71+
if errors.Is(err, util.ErrNotExist) {
72+
ctx.Data["NotFoundPrompt"] = ctx.Tr("repo.branch.default_branch_not_exist", ctx.Repo.Repository.DefaultBranch)
73+
ctx.NotFound(nil)
74+
return
75+
} else if err != nil {
7176
ctx.ServerError("GetBranchCommit", err)
7277
return
7378
}

routers/web/repo/activity.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
activities_model "code.gitea.io/gitea/models/activities"
11+
"code.gitea.io/gitea/models/git"
1112
"code.gitea.io/gitea/models/unit"
1213
"code.gitea.io/gitea/modules/templates"
1314
"code.gitea.io/gitea/services/context"
@@ -52,6 +53,12 @@ func Activity(ctx *context.Context) {
5253
ctx.Data["DateUntil"] = timeUntil
5354
ctx.Data["PeriodText"] = ctx.Tr("repo.activity.period." + ctx.Data["Period"].(string))
5455

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
61+
}
5562
var err error
5663
if ctx.Data["Activity"], err = activities_model.GetActivityStats(ctx, ctx.Repo.Repository, timeFrom,
5764
ctx.Repo.CanRead(unit.TypeReleases),

services/context/context_response.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (ctx *Context) notFoundInternal(logMsg string, logErr error) {
150150

151151
ctx.Data["IsRepo"] = ctx.Repo.Repository != nil
152152
ctx.Data["Title"] = "Page Not Found"
153-
ctx.HTML(http.StatusNotFound, templates.TplName("status/404"))
153+
ctx.HTML(http.StatusNotFound, "status/404")
154154
}
155155

156156
// ServerError displays a 500 (Internal Server Error) page and prints the given error, if any.

0 commit comments

Comments
 (0)