forked from forgejo/forgejo
[GITEA] Add repo empty check for branch feed
- If you attempted to get a branch feed on a empty repository, it would result in a panic as the code expects that the branch exists. - `context.RepoRefByType` would normally already 404 if the branch doesn't exist, however if a repository is empty, it would not do this check. - Fix bug where `/atom/branch/*` would return a RSS feed. (cherry picked from commitd27bcd98a4
) (cherry picked from commitc58566403d
) (cherry picked from commitb8b3f6ab8b
) (cherry picked from commit195520100b
) (cherry picked from commit6e417087dd
) (cherry picked from commitff91e5957a
) (cherry picked from commit6626d5cc75
) (cherry picked from commit62f8ab793b
) (cherry picked from commite5bbf1a2d0
) (cherry picked from commitf5b8c8edea
) (cherry picked from commit50948fa11b
)
This commit is contained in:
parent
bd9ac9ac6f
commit
83a9f7f442
4 changed files with 73 additions and 14 deletions
|
@ -740,12 +740,19 @@ func Home(ctx *context.Context) {
|
|||
if setting.Other.EnableFeed {
|
||||
isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req)
|
||||
if isFeed {
|
||||
switch {
|
||||
case ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType):
|
||||
if ctx.Link == fmt.Sprintf("%s.%s", ctx.Repo.RepoLink, showFeedType) {
|
||||
feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType)
|
||||
case ctx.Repo.TreePath == "":
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.Repository.IsEmpty {
|
||||
ctx.NotFound("MustBeNotEmpty", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.Repo.TreePath == "" {
|
||||
feed.ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType)
|
||||
case ctx.Repo.TreePath != "":
|
||||
} else {
|
||||
feed.ShowFileFeed(ctx, ctx.Repo.Repository, showFeedType)
|
||||
}
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue