diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2025-01-25 22:36:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-25 14:36:47 +0000 |
commit | 2c1ff8701a7aeafc86f87c286514768cdf121ccb (patch) | |
tree | ed398c8afa3d6b0c84136cc756f12d76dd585279 /routers/web/repo | |
parent | 6a516a0d14907d3bee390696f31bea3cd8a83418 (diff) | |
download | gitea-2c1ff8701a7aeafc86f87c286514768cdf121ccb.tar.gz gitea-2c1ff8701a7aeafc86f87c286514768cdf121ccb.zip |
Refactor context flash msg and global variables (#33375)
1. add `GetSiteCookieFlashMessage` to help to parse flash message
2. clarify `handleRepoHomeFeed` logic
3. remove unnecessary global variables, use `sync.OnceValue` instead
4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
Diffstat (limited to 'routers/web/repo')
-rw-r--r-- | routers/web/repo/view_home.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/routers/web/repo/view_home.go b/routers/web/repo/view_home.go index d141df181c..456efb96f6 100644 --- a/routers/web/repo/view_home.go +++ b/routers/web/repo/view_home.go @@ -311,21 +311,21 @@ func prepareToRenderDirOrFile(entry *git.TreeEntry) func(ctx *context.Context) { } func handleRepoHomeFeed(ctx *context.Context) bool { - if setting.Other.EnableFeed { - isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam("reponame"), ctx.Req) - if isFeed { - switch { - case ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType): - feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType) - case ctx.Repo.TreePath == "": - feed.ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType) - case ctx.Repo.TreePath != "": - feed.ShowFileFeed(ctx, ctx.Repo.Repository, showFeedType) - } - return true - } + if !setting.Other.EnableFeed { + return false + } + isFeed, showFeedType := feed.GetFeedType(ctx.PathParam("reponame"), ctx.Req) + if !isFeed { + return false + } + if ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType) { + feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType) + } else if ctx.Repo.TreePath == "" { + feed.ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType) + } else { + feed.ShowFileFeed(ctx, ctx.Repo.Repository, showFeedType) } - return false + return true } // Home render repository home page |