mirror of https://codeberg.org/forgejo/forgejo.git
Compare commits
9 Commits
5357f2820f
...
99bb721c3c
Author | SHA1 | Date |
---|---|---|
Renovate Bot | 99bb721c3c | |
Earl Warren | 27fa12427c | |
Beowulf | c54896ba70 | |
Earl Warren | de9d498109 | |
Otto | 641ddbbbb9 | |
Otto Richter | bc8860ce32 | |
Otto Richter | 4b8f0d0972 | |
Robin Kloppe | 10cd0f3992 | |
Otto Richter | 5c76c37a50 |
|
@ -22,7 +22,7 @@ jobs:
|
|||
|
||||
runs-on: docker
|
||||
container:
|
||||
image: ghcr.io/visualon/renovate:37.323.3
|
||||
image: ghcr.io/visualon/renovate:37.326.2
|
||||
|
||||
steps:
|
||||
- name: Load renovate repo cache
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
The default config for `database.MAX_OPEN_CONNS` changed from 0 (unlimited) to 100 to avoid problems if it exceeds the limit by the database server. If you require high concurrency, try to increase this value for both Forgejo **and your database server**. [`Limit database max connections by default`](https://codeberg.org/forgejo/forgejo/pulls/3383)
|
|
@ -57,7 +57,7 @@ func Activity(ctx *context.Context) {
|
|||
ctx.Repo.CanRead(unit.TypeReleases),
|
||||
ctx.Repo.CanRead(unit.TypeIssues),
|
||||
ctx.Repo.CanRead(unit.TypePullRequests),
|
||||
ctx.Repo.CanRead(unit.TypeCode)); err != nil {
|
||||
ctx.Repo.CanRead(unit.TypeCode) && !ctx.Repo.Repository.IsEmpty); err != nil {
|
||||
ctx.ServerError("GetActivityStats", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
tplWatching base.TplName = "repo/issue/view_content/watching"
|
||||
tplWatching base.TplName = "repo/issue/view_content/sidebar/watching"
|
||||
)
|
||||
|
||||
// IssueWatch sets issue watching
|
||||
|
|
|
@ -1423,16 +1423,16 @@ func registerRoutes(m *web.Route) {
|
|||
m.Group("/contributors", func() {
|
||||
m.Get("", repo.Contributors)
|
||||
m.Get("/data", repo.ContributorsData)
|
||||
})
|
||||
}, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode))
|
||||
m.Group("/code-frequency", func() {
|
||||
m.Get("", repo.CodeFrequency)
|
||||
m.Get("/data", repo.CodeFrequencyData)
|
||||
})
|
||||
}, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode))
|
||||
m.Group("/recent-commits", func() {
|
||||
m.Get("", repo.RecentCommits)
|
||||
m.Get("/data", repo.RecentCommitsData)
|
||||
})
|
||||
}, context.RepoRef(), repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases))
|
||||
}, repo.MustBeNotEmpty, context.RequireRepoReaderOr(unit.TypeCode))
|
||||
}, context.RepoRef(), context.RequireRepoReaderOr(unit.TypeCode, unit.TypePullRequests, unit.TypeIssues, unit.TypeReleases))
|
||||
|
||||
m.Group("/activity_author_data", func() {
|
||||
m.Get("", repo.ActivityAuthors)
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
<div role="main" aria-label="{{.Title}}" class="page-content repository commits">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container flex-container">
|
||||
<div class="flex-container-nav">
|
||||
{{template "repo/navbar" .}}
|
||||
</div>
|
||||
{{if and (not .IsEmptyRepo) (.Permission.CanRead $.UnitTypeCode)}}
|
||||
<div class="flex-container-nav">
|
||||
{{template "repo/navbar" .}}
|
||||
</div>
|
||||
{{end}}
|
||||
<div class="flex-container-main">
|
||||
{{if .PageIsPulse}}{{template "repo/pulse" .}}{{end}}
|
||||
{{if .PageIsContributors}}{{template "repo/contributors" .}}{{end}}
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
</a>
|
||||
{{end}}
|
||||
|
||||
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
|
||||
{{if and (.Permission.CanReadAny $.UnitTypeCode $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases)}}
|
||||
<a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
|
||||
{{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}}
|
||||
</a>
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
<div class="ui watching">
|
||||
<span class="text"><strong>{{ctx.Locale.Tr "notification.notifications"}}</strong></span>
|
||||
<div class="tw-mt-2">
|
||||
<form hx-boost="true" hx-sync="this:replace" hx-target="this" method="post" action="{{.Issue.Link}}/watch">
|
||||
<input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}">
|
||||
<button class="fluid ui button">
|
||||
{{if $.IssueWatch.IsWatching}}
|
||||
{{svg "octicon-mute" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.Tr "repo.issues.unsubscribe"}}
|
||||
{{else}}
|
||||
{{svg "octicon-unmute" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.Tr "repo.issues.subscribe"}}
|
||||
{{end}}
|
||||
</button>
|
||||
</form>
|
||||
{{template "repo/issue/view_content/sidebar/watching" .}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<form hx-boost="true" hx-sync="this:replace" hx-target="this" method="post" action="{{.Issue.Link}}/watch">
|
||||
<input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}">
|
||||
<button class="fluid ui button">
|
||||
{{if $.IssueWatch.IsWatching}}
|
||||
{{svg "octicon-mute" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.Tr "repo.issues.unsubscribe"}}
|
||||
{{else}}
|
||||
{{svg "octicon-unmute" 16 "tw-mr-2"}}
|
||||
{{ctx.Locale.Tr "repo.issues.subscribe"}}
|
||||
{{end}}
|
||||
</button>
|
||||
</form>
|
|
@ -86,18 +86,18 @@
|
|||
{{else}}
|
||||
{{if $newMirrorsEntirelyEnabled}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs"}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pushing-to-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pushing-to-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}</a><br>
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_pull_section"}}</a><br>
|
||||
{{else if $onlyNewPushMirrorsEnabled}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br>
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br>
|
||||
{{else if $onlyNewPullMirrorsEnabled}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.more_information_if_disabled"}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com/usage/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
||||
<a target="_blank" rel="noopener noreferrer" href="https://forgejo.org/docs/latest/user/repo-mirror#pulling-from-a-remote-repository">{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br>
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}}
|
||||
{{if $existingPushMirror}}
|
||||
{{ctx.Locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}
|
||||
|
|
|
@ -4,13 +4,20 @@
|
|||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
unit_model "code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
repo_service "code.gitea.io/gitea/services/repository"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -63,3 +70,122 @@ func TestRepoActivity(t *testing.T) {
|
|||
assert.Len(t, list.Nodes, 3)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRepoActivityAllUnitsDisabled(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
unit_model.LoadUnitConfig()
|
||||
|
||||
// Create a repo, with no unit enabled.
|
||||
repo, err := repo_service.CreateRepository(db.DefaultContext, user, user, repo_service.CreateRepoOptions{
|
||||
Name: "empty-repo",
|
||||
AutoInit: false,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, repo)
|
||||
|
||||
enabledUnits := make([]repo_model.RepoUnit, 0)
|
||||
disabledUnits := []unit_model.Type{unit_model.TypeCode, unit_model.TypeIssues, unit_model.TypePullRequests, unit_model.TypeReleases}
|
||||
err = repo_service.UpdateRepositoryUnits(db.DefaultContext, repo, enabledUnits, disabledUnits)
|
||||
assert.NoError(t, err)
|
||||
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/activity", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/contributors", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/code-frequency", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/recent-commits", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestRepoActivityOnlyCodeUnitWithEmptyRepo(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
unit_model.LoadUnitConfig()
|
||||
|
||||
// Create a empty repo, with only code unit enabled.
|
||||
repo, err := repo_service.CreateRepository(db.DefaultContext, user, user, repo_service.CreateRepoOptions{
|
||||
Name: "empty-repo",
|
||||
AutoInit: false,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, repo)
|
||||
|
||||
enabledUnits := make([]repo_model.RepoUnit, 1)
|
||||
enabledUnits[0] = repo_model.RepoUnit{RepoID: repo.ID, Type: unit_model.TypeCode}
|
||||
disabledUnits := []unit_model.Type{unit_model.TypeIssues, unit_model.TypePullRequests, unit_model.TypeReleases}
|
||||
err = repo_service.UpdateRepositoryUnits(db.DefaultContext, repo, enabledUnits, disabledUnits)
|
||||
assert.NoError(t, err)
|
||||
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/activity", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// Git repo empty so no activity for contributors etc
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/contributors", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/code-frequency", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/recent-commits", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestRepoActivityOnlyCodeUnitWithNonEmptyRepo(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
unit_model.LoadUnitConfig()
|
||||
|
||||
// Create a repo, with only code unit enabled.
|
||||
repo, _, f := CreateDeclarativeRepo(t, user, "", []unit_model.Type{unit_model.TypeCode}, nil, nil)
|
||||
defer f()
|
||||
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/activity", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// Git repo not empty so activity for contributors etc
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/contributors", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/code-frequency", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/recent-commits", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
}
|
||||
|
||||
func TestRepoActivityOnlyIssuesUnit(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user1"})
|
||||
session := loginUser(t, user.Name)
|
||||
|
||||
unit_model.LoadUnitConfig()
|
||||
|
||||
// Create a empty repo, with only code unit enabled.
|
||||
repo, err := repo_service.CreateRepository(db.DefaultContext, user, user, repo_service.CreateRepoOptions{
|
||||
Name: "empty-repo",
|
||||
AutoInit: false,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, repo)
|
||||
|
||||
enabledUnits := make([]repo_model.RepoUnit, 1)
|
||||
enabledUnits[0] = repo_model.RepoUnit{RepoID: repo.ID, Type: unit_model.TypeIssues}
|
||||
disabledUnits := []unit_model.Type{unit_model.TypeCode, unit_model.TypePullRequests, unit_model.TypeReleases}
|
||||
err = repo_service.UpdateRepositoryUnits(db.DefaultContext, repo, enabledUnits, disabledUnits)
|
||||
assert.NoError(t, err)
|
||||
|
||||
req := NewRequest(t, "GET", fmt.Sprintf("%s/activity", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
// Git repo empty so no activity for contributors etc
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/contributors", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/code-frequency", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
req = NewRequest(t, "GET", fmt.Sprintf("%s/activity/recent-commits", repo.Link()))
|
||||
session.MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue