mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Improvements of releases list and tags list (#25859)
Follow #23465 and #25624 This PR introduces the following improvements: - We do not need to call `GetTags` to get tags because tags have been loaded by `RepoAssignment`ef90fdbd1d/modules/context/repo.go (L663-L668)
- Similarly, the number of tags and releases also have been loaded by `RepoAssignment`, so the related code has been removed from the handlers. The query condition of `GetReleaseCountByRepoID` in `RepoAssignment` has been changed to include draft releases.ef90fdbd1d/modules/context/repo.go (L538-L551)
- `releasesOrTags` function has been removed. The code for rendering releases list and tags list moved to `Releases` and `TagList` respectively.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
@@ -65,7 +66,7 @@ func TestNewReleasePost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewReleasesList(t *testing.T) {
|
||||
func TestCalReleaseNumCommitsBehind(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo-release/releases")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
@@ -73,8 +74,17 @@ func TestNewReleasesList(t *testing.T) {
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
t.Cleanup(func() { ctx.Repo.GitRepo.Close() })
|
||||
|
||||
Releases(ctx)
|
||||
releases := ctx.Data["Releases"].([]*repo_model.Release)
|
||||
releases, err := repo_model.GetReleasesByRepoID(ctx, ctx.Repo.Repository.ID, repo_model.FindReleasesOptions{
|
||||
IncludeDrafts: ctx.Repo.CanWrite(unit.TypeReleases),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
countCache := make(map[string]int64)
|
||||
for _, release := range releases {
|
||||
err := calReleaseNumCommitsBehind(ctx.Repo, release, countCache)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
type computedFields struct {
|
||||
NumCommitsBehind int64
|
||||
TargetBehind string
|
||||
|
Reference in New Issue
Block a user