From 9a35b6ba77fd459eec5956dbf9732b845761305c Mon Sep 17 00:00:00 2001 From: 0ko <0ko@noreply.codeberg.org> Date: Sat, 11 Oct 2025 01:52:51 +0200 Subject: [PATCH] chore: remove branding from context imports (#9628) Kind of followup to https://codeberg.org/forgejo/forgejo/pulls/7337. With cherry-picking being no more, this shouldn't cause too much chaos. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9628 Reviewed-by: Gusted Co-authored-by: 0ko <0ko@noreply.codeberg.org> Co-committed-by: 0ko <0ko@noreply.codeberg.org> --- routers/private/default_branch.go | 4 ++-- routers/private/hook_post_receive.go | 6 +++--- routers/private/hook_pre_receive.go | 6 +++--- routers/private/hook_proc_receive.go | 4 ++-- routers/private/internal_repo.go | 8 ++++---- services/auth/auth.go | 4 ++-- services/markup/processorhelper.go | 6 +++--- services/markup/processorhelper_test.go | 6 +++--- services/pull/pull.go | 4 ++-- services/webhook/discord.go | 4 ++-- services/webhook/slack.go | 4 ++-- services/webhook/sourcehut/builds.go | 4 ++-- tests/integration/api_packages_cargo_test.go | 6 +++--- tests/integration/branches_test.go | 6 +++--- tests/integration/editor_test.go | 6 +++--- .../integration/forgejo_confirmation_repo_test.go | 12 ++++++------ tests/integration/git_test.go | 4 ++-- tests/integration/integration_test.go | 8 ++++---- tests/integration/mirror_push_test.go | 14 +++++++------- tests/integration/pull_reopen_test.go | 6 +++--- tests/integration/rename_branch_test.go | 8 ++++---- tests/integration/repo_settings_test.go | 4 ++-- tests/integration/repo_webhook_test.go | 4 ++-- tests/integration/user_test.go | 6 +++--- 24 files changed, 72 insertions(+), 72 deletions(-) diff --git a/routers/private/default_branch.go b/routers/private/default_branch.go index da185e1ab1..7e99e57b4b 100644 --- a/routers/private/default_branch.go +++ b/routers/private/default_branch.go @@ -10,11 +10,11 @@ import ( repo_model "forgejo.org/models/repo" "forgejo.org/modules/gitrepo" "forgejo.org/modules/private" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" ) // SetDefaultBranch updates the default branch -func SetDefaultBranch(ctx *gitea_context.PrivateContext) { +func SetDefaultBranch(ctx *app_context.PrivateContext) { ownerName := ctx.Params(":owner") repoName := ctx.Params(":repo") branch := ctx.Params(":branch") diff --git a/routers/private/hook_post_receive.go b/routers/private/hook_post_receive.go index a856a7a00a..0acc09ab1b 100644 --- a/routers/private/hook_post_receive.go +++ b/routers/private/hook_post_receive.go @@ -27,12 +27,12 @@ import ( timeutil "forgejo.org/modules/timeutil" "forgejo.org/modules/util" "forgejo.org/modules/web" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" repo_service "forgejo.org/services/repository" ) // HookPostReceive updates services and users -func HookPostReceive(ctx *gitea_context.PrivateContext) { +func HookPostReceive(ctx *app_context.PrivateContext) { opts := web.GetForm(ctx).(*private.HookOptions) // We don't rely on RepoAssignment here because: @@ -325,7 +325,7 @@ func loadContextCacheUser(ctx context.Context, id int64) (*user_model.User, erro } // handlePullRequestMerging handle pull request merging, a pull request action should push at least 1 commit -func handlePullRequestMerging(ctx *gitea_context.PrivateContext, opts *private.HookOptions, ownerName, repoName string, updates []*repo_module.PushUpdateOptions) { +func handlePullRequestMerging(ctx *app_context.PrivateContext, opts *private.HookOptions, ownerName, repoName string, updates []*repo_module.PushUpdateOptions) { if len(updates) == 0 { ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{ Err: fmt.Sprintf("Pushing a merged PR (pr:%d) no commits pushed ", opts.PullRequestID), diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go index 45992e8522..217e5d817f 100644 --- a/routers/private/hook_pre_receive.go +++ b/routers/private/hook_pre_receive.go @@ -23,12 +23,12 @@ import ( "forgejo.org/modules/private" "forgejo.org/modules/setting" "forgejo.org/modules/web" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" pull_service "forgejo.org/services/pull" ) type preReceiveContext struct { - *gitea_context.PrivateContext + *app_context.PrivateContext // loadedPusher indicates that where the following information are loaded loadedPusher bool @@ -175,7 +175,7 @@ func (ctx *preReceiveContext) quotaExceeded() { } // HookPreReceive checks whether a individual commit is acceptable -func HookPreReceive(ctx *gitea_context.PrivateContext) { +func HookPreReceive(ctx *app_context.PrivateContext) { opts := web.GetForm(ctx).(*private.HookOptions) ourCtx := &preReceiveContext{ diff --git a/routers/private/hook_proc_receive.go b/routers/private/hook_proc_receive.go index 9f6e23f158..167036821b 100644 --- a/routers/private/hook_proc_receive.go +++ b/routers/private/hook_proc_receive.go @@ -11,11 +11,11 @@ import ( "forgejo.org/modules/private" "forgejo.org/modules/web" "forgejo.org/services/agit" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" ) // HookProcReceive proc-receive hook - only handles agit Proc-Receive requests at present -func HookProcReceive(ctx *gitea_context.PrivateContext) { +func HookProcReceive(ctx *app_context.PrivateContext) { opts := web.GetForm(ctx).(*private.HookOptions) results, err := agit.ProcReceive(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, opts) diff --git a/routers/private/internal_repo.go b/routers/private/internal_repo.go index f237d2c676..dec020878f 100644 --- a/routers/private/internal_repo.go +++ b/routers/private/internal_repo.go @@ -12,13 +12,13 @@ import ( "forgejo.org/modules/gitrepo" "forgejo.org/modules/log" "forgejo.org/modules/private" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" ) // This file contains common functions relating to setting the Repository for the internal routes // RepoAssignment assigns the repository and gitrepository to the private context -func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc { +func RepoAssignment(ctx *app_context.PrivateContext) context.CancelFunc { ownerName := ctx.Params(":owner") repoName := ctx.Params(":repo") @@ -37,7 +37,7 @@ func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc { return nil } - ctx.Repo = &gitea_context.Repository{ + ctx.Repo = &app_context.Repository{ Repository: repo, GitRepo: gitRepo, } @@ -53,7 +53,7 @@ func RepoAssignment(ctx *gitea_context.PrivateContext) context.CancelFunc { return cancel } -func loadRepository(ctx *gitea_context.PrivateContext, ownerName, repoName string) *repo_model.Repository { +func loadRepository(ctx *app_context.PrivateContext, ownerName, repoName string) *repo_model.Repository { repo, err := repo_model.GetRepositoryByOwnerAndName(ctx, ownerName, repoName) if err != nil { log.Error("Failed to get repository: %s/%s Error: %v", ownerName, repoName, err) diff --git a/services/auth/auth.go b/services/auth/auth.go index 85121b2d7f..dc7a283aa9 100644 --- a/services/auth/auth.go +++ b/services/auth/auth.go @@ -17,7 +17,7 @@ import ( "forgejo.org/modules/session" "forgejo.org/modules/setting" "forgejo.org/modules/web/middleware" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" user_service "forgejo.org/services/user" ) @@ -101,7 +101,7 @@ func handleSignIn(resp http.ResponseWriter, req *http.Request, sess SessionStore middleware.SetLocaleCookie(resp, user.Language, 0) // Clear whatever CSRF has right now, force to generate a new one - if ctx := gitea_context.GetWebContext(req); ctx != nil { + if ctx := app_context.GetWebContext(req); ctx != nil { ctx.Csrf.DeleteCookie(ctx) } } diff --git a/services/markup/processorhelper.go b/services/markup/processorhelper.go index 2f1b1e738c..ea747645b0 100644 --- a/services/markup/processorhelper.go +++ b/services/markup/processorhelper.go @@ -15,7 +15,7 @@ import ( "forgejo.org/modules/gitrepo" "forgejo.org/modules/log" "forgejo.org/modules/markup" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" file_service "forgejo.org/services/repository/files" ) @@ -28,7 +28,7 @@ func ProcessorHelper() *markup.ProcessorHelper { return false } - giteaCtx, ok := ctx.(*gitea_context.Context) + giteaCtx, ok := ctx.(*app_context.Context) if !ok { // when using general context, use user's visibility to check return mentionedUser.Visibility.IsPublic() @@ -45,7 +45,7 @@ func ProcessorHelper() *markup.ProcessorHelper { var user *user.User - giteaCtx, ok := ctx.(*gitea_context.Context) + giteaCtx, ok := ctx.(*app_context.Context) if ok { user = giteaCtx.Doer } diff --git a/services/markup/processorhelper_test.go b/services/markup/processorhelper_test.go index 8195451746..2494306d07 100644 --- a/services/markup/processorhelper_test.go +++ b/services/markup/processorhelper_test.go @@ -11,7 +11,7 @@ import ( "forgejo.org/models/db" "forgejo.org/models/unittest" "forgejo.org/models/user" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/contexttest" "github.com/stretchr/testify/assert" @@ -40,9 +40,9 @@ func TestProcessorHelper(t *testing.T) { // when using web context, use user.IsUserVisibleToViewer to check req, err := http.NewRequest("GET", "/", nil) require.NoError(t, err) - base, baseCleanUp := gitea_context.NewBaseContext(httptest.NewRecorder(), req) + base, baseCleanUp := app_context.NewBaseContext(httptest.NewRecorder(), req) defer baseCleanUp() - giteaCtx := gitea_context.NewWebContext(base, &contexttest.MockRender{}, nil) + giteaCtx := app_context.NewWebContext(base, &contexttest.MockRender{}, nil) assert.True(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPublic)) assert.False(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPrivate)) diff --git a/services/pull/pull.go b/services/pull/pull.go index c1fe6c6b55..6a6be319c4 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -28,7 +28,7 @@ import ( repo_module "forgejo.org/modules/repository" "forgejo.org/modules/setting" "forgejo.org/modules/sync" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" issue_service "forgejo.org/services/issue" notify_service "forgejo.org/services/notify" ) @@ -911,7 +911,7 @@ type CommitInfo struct { // GetPullCommits returns all commits on given pull request and the last review commit sha // Attention: The last review commit sha must be from the latest review whose commit id is not empty. // So the type of the latest review cannot be "ReviewTypeRequest". -func GetPullCommits(ctx *gitea_context.Context, issue *issues_model.Issue) ([]CommitInfo, string, error) { +func GetPullCommits(ctx *app_context.Context, issue *issues_model.Issue) ([]CommitInfo, string, error) { pull := issue.PullRequest baseGitRepo := ctx.Repo.GitRepo diff --git a/services/webhook/discord.go b/services/webhook/discord.go index 7259c4a995..330498f630 100644 --- a/services/webhook/discord.go +++ b/services/webhook/discord.go @@ -24,7 +24,7 @@ import ( api "forgejo.org/modules/structs" "forgejo.org/modules/util" webhook_module "forgejo.org/modules/webhook" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/forms" "forgejo.org/services/webhook/shared" @@ -47,7 +47,7 @@ var _ binding.Validator = &discordForm{} // Validate implements binding.Validator. func (d *discordForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { - ctx := gitea_context.GetWebContext(req) + ctx := app_context.GetWebContext(req) if len([]rune(d.IconURL)) > 2048 { errs = append(errs, binding.Error{ FieldNames: []string{"IconURL"}, diff --git a/services/webhook/slack.go b/services/webhook/slack.go index 8c61e7ba25..e44cc09297 100644 --- a/services/webhook/slack.go +++ b/services/webhook/slack.go @@ -17,7 +17,7 @@ import ( "forgejo.org/modules/log" api "forgejo.org/modules/structs" webhook_module "forgejo.org/modules/webhook" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/forms" "forgejo.org/services/webhook/shared" @@ -42,7 +42,7 @@ var _ binding.Validator = &slackForm{} // Validate implements binding.Validator. func (s *slackForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { - ctx := gitea_context.GetWebContext(req) + ctx := app_context.GetWebContext(req) if !IsValidSlackChannel(strings.TrimSpace(s.Channel)) { errs = append(errs, binding.Error{ FieldNames: []string{"Channel"}, diff --git a/services/webhook/sourcehut/builds.go b/services/webhook/sourcehut/builds.go index 96ed55c8ff..a3efa2a5a7 100644 --- a/services/webhook/sourcehut/builds.go +++ b/services/webhook/sourcehut/builds.go @@ -21,7 +21,7 @@ import ( "forgejo.org/modules/setting" api "forgejo.org/modules/structs" webhook_module "forgejo.org/modules/webhook" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/forms" "forgejo.org/services/webhook/shared" @@ -57,7 +57,7 @@ var _ binding.Validator = &buildsForm{} // Validate implements binding.Validator. func (f *buildsForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { - ctx := gitea_context.GetWebContext(req) + ctx := app_context.GetWebContext(req) if !fs.ValidPath(f.ManifestPath) { errs = append(errs, binding.Error{ FieldNames: []string{"ManifestPath"}, diff --git a/tests/integration/api_packages_cargo_test.go b/tests/integration/api_packages_cargo_test.go index 9e03d9e8a8..a86c2c64ad 100644 --- a/tests/integration/api_packages_cargo_test.go +++ b/tests/integration/api_packages_cargo_test.go @@ -22,7 +22,7 @@ import ( cargo_module "forgejo.org/modules/packages/cargo" "forgejo.org/modules/setting" cargo_router "forgejo.org/routers/api/packages/cargo" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" cargo_service "forgejo.org/services/packages/cargo" "forgejo.org/tests" @@ -401,7 +401,7 @@ func TestRebuildCargo(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "error%3DCannot%2Brebuild%252C%2Bno%2Bindex%2Bis%2Binitialized.", flashCookie.Value) unittest.AssertExistsIf(t, false, &repo_model.Repository{OwnerID: user.ID, Name: cargo_service.IndexRepositoryName}) @@ -439,7 +439,7 @@ func TestRebuildCargo(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThe%2BCargo%2Bindex%2Bwas%2Bsuccessfully%2Brebuilt.", flashCookie.Value) }) diff --git a/tests/integration/branches_test.go b/tests/integration/branches_test.go index c599106866..ed5d78bd78 100644 --- a/tests/integration/branches_test.go +++ b/tests/integration/branches_test.go @@ -12,7 +12,7 @@ import ( git_model "forgejo.org/models/git" repo_model "forgejo.org/models/repo" "forgejo.org/models/unittest" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "github.com/stretchr/testify/assert" ) @@ -35,7 +35,7 @@ func TestBranchActions(t *testing.T) { "_csrf": GetCSRF(t, session, branchesLink), }) session.MakeRequest(t, req, http.StatusOK) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DBranch%2B%2522branch2%2522%2Bhas%2Bbeen%2Bdeleted.") @@ -48,7 +48,7 @@ func TestBranchActions(t *testing.T) { "_csrf": GetCSRF(t, session, branchesLink), }) session.MakeRequest(t, req, http.StatusOK) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DBranch%2B%2522branch2%2522%2Bhas%2Bbeen%2Brestored") diff --git a/tests/integration/editor_test.go b/tests/integration/editor_test.go index bc2c4dcb84..3dbfbd899e 100644 --- a/tests/integration/editor_test.go +++ b/tests/integration/editor_test.go @@ -21,7 +21,7 @@ import ( "forgejo.org/modules/git" "forgejo.org/modules/json" "forgejo.org/modules/translation" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/tests" "github.com/stretchr/testify/assert" @@ -41,7 +41,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) // Check if master branch has been locked successfully - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522master%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value) @@ -82,7 +82,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) { assert.Equal(t, "/user2/repo1/settings/branches", res["redirect"]) // Check if master branch has been locked successfully - flashCookie = session.GetCookie(gitea_context.CookieNameFlash) + flashCookie = session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "error%3DRemoving%2Bbranch%2Bprotection%2Brule%2B%25221%2522%2Bfailed.", flashCookie.Value) }) diff --git a/tests/integration/forgejo_confirmation_repo_test.go b/tests/integration/forgejo_confirmation_repo_test.go index 28d6777aea..985e99b2c7 100644 --- a/tests/integration/forgejo_confirmation_repo_test.go +++ b/tests/integration/forgejo_confirmation_repo_test.go @@ -9,7 +9,7 @@ import ( "testing" "forgejo.org/modules/translation" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/tests" "github.com/stretchr/testify/assert" @@ -53,7 +53,7 @@ func TestDangerZoneConfirmation(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThis%2Brepository%2Bhas%2Bbeen%2Bmarked%2Bfor%2Btransfer%2Band%2Bawaits%2Bconfirmation%2Bfrom%2B%2522User%2BOne%2522", flashCookie.Value) }) @@ -83,7 +83,7 @@ func TestDangerZoneConfirmation(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThe%2Bfork%2Bhas%2Bbeen%2Bconverted%2Binto%2Ba%2Bregular%2Brepository.", flashCookie.Value) }) @@ -116,7 +116,7 @@ func TestDangerZoneConfirmation(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThe%2Brepository%2Bwiki%2527s%2Bbranch%2Bname%2Bhas%2Bbeen%2Bsuccessfully%2Bnormalized.", flashCookie.Value) }) @@ -146,7 +146,7 @@ func TestDangerZoneConfirmation(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThe%2Brepository%2Bwiki%2Bdata%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value) }) @@ -176,7 +176,7 @@ func TestDangerZoneConfirmation(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DThe%2Brepository%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value) }) diff --git a/tests/integration/git_test.go b/tests/integration/git_test.go index fcd81cf6b2..e865496bce 100644 --- a/tests/integration/git_test.go +++ b/tests/integration/git_test.go @@ -34,7 +34,7 @@ import ( "forgejo.org/modules/lfs" "forgejo.org/modules/setting" api "forgejo.org/modules/structs" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" files_service "forgejo.org/services/repository/files" "forgejo.org/tests" @@ -495,7 +495,7 @@ func doProtectBranch(ctx APITestContext, branch string, addParameter ...paramete req := NewRequestWithValues(t, "POST", fmt.Sprintf("/%s/%s/settings/branches/edit", url.PathEscape(ctx.Username), url.PathEscape(ctx.Reponame)), parameter) ctx.Session.MakeRequest(t, req, http.StatusSeeOther) // Check if master branch has been locked successfully - flashCookie := ctx.Session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := ctx.Session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522"+url.QueryEscape(branch)+"%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value) } diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index ac3c86e332..3ee6882e3b 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -41,7 +41,7 @@ import ( "forgejo.org/modules/web" "forgejo.org/routers" "forgejo.org/services/auth/source/remote" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/mailer" user_service "forgejo.org/services/user" "forgejo.org/tests" @@ -297,7 +297,7 @@ func (s *TestSession) EnrollTOTP(t testing.TB) { }) s.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := s.GetCookie(gitea_context.CookieNameFlash) + flashCookie := s.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DYour%2Baccount%2Bhas%2Bbeen%2Bsuccessfully%2Benrolled.") } @@ -522,7 +522,7 @@ func createApplicationSettingsToken(t testing.TB, session *TestSession, name str // Log the flash values on failure if !assert.Equal(t, []string{"/user/settings/applications"}, resp.Result().Header["Location"]) { for _, cookie := range resp.Result().Cookies() { - if cookie.Name != gitea_context.CookieNameFlash { + if cookie.Name != app_context.CookieNameFlash { continue } flash, _ := url.ParseQuery(cookie.Value) @@ -668,7 +668,7 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) { if len(respBytes) == 0 { // log the content of the flash cookie for _, cookie := range recorder.Result().Cookies() { - if cookie.Name != gitea_context.CookieNameFlash { + if cookie.Name != app_context.CookieNameFlash { continue } flash, _ := url.ParseQuery(cookie.Value) diff --git a/tests/integration/mirror_push_test.go b/tests/integration/mirror_push_test.go index 23bb550d9f..b47a793a9e 100644 --- a/tests/integration/mirror_push_test.go +++ b/tests/integration/mirror_push_test.go @@ -31,7 +31,7 @@ import ( api "forgejo.org/modules/structs" "forgejo.org/modules/test" "forgejo.org/modules/translation" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" doctor "forgejo.org/services/doctor" "forgejo.org/services/migrations" mirror_service "forgejo.org/services/mirror" @@ -173,7 +173,7 @@ func doCreatePushMirror(ctx APITestContext, address, username, password string) }) ctx.Session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := ctx.Session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := ctx.Session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") } @@ -194,7 +194,7 @@ func doCreatePushMirrorWithBranchFilter(ctx APITestContext, address, username, p }) ctx.Session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := ctx.Session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := ctx.Session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") } @@ -215,7 +215,7 @@ func doRemovePushMirror(ctx APITestContext, address, username, password string, }) ctx.Session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := ctx.Session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := ctx.Session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") } @@ -308,7 +308,7 @@ func TestSSHPushMirror(t *testing.T) { }) sess.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := sess.GetCookie(gitea_context.CookieNameFlash) + flashCookie := sess.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") @@ -615,7 +615,7 @@ func TestPushMirrorSettings(t *testing.T) { }) sess.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := sess.GetCookie(gitea_context.CookieNameFlash) + flashCookie := sess.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") }) @@ -650,7 +650,7 @@ func TestPushMirrorSettings(t *testing.T) { }) sess.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := sess.GetCookie(gitea_context.CookieNameFlash) + flashCookie := sess.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") }) diff --git a/tests/integration/pull_reopen_test.go b/tests/integration/pull_reopen_test.go index cf95f6b730..abb647c114 100644 --- a/tests/integration/pull_reopen_test.go +++ b/tests/integration/pull_reopen_test.go @@ -20,7 +20,7 @@ import ( user_model "forgejo.org/models/user" "forgejo.org/modules/git" "forgejo.org/modules/translation" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" issue_service "forgejo.org/services/issue" pull_service "forgejo.org/services/pull" repo_service "forgejo.org/services/repository" @@ -152,7 +152,7 @@ func TestPullrequestReopen(t *testing.T) { }) session.MakeRequest(t, req, http.StatusOK) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DBranch%2B%2522"+branchName+"%2522%2Bhas%2Bbeen%2Brestored.") } @@ -166,7 +166,7 @@ func TestPullrequestReopen(t *testing.T) { }) session.MakeRequest(t, req, http.StatusOK) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DBranch%2B%2522"+branchName+"%2522%2Bhas%2Bbeen%2Bdeleted.") } diff --git a/tests/integration/rename_branch_test.go b/tests/integration/rename_branch_test.go index 2029a3732b..6dfebc3976 100644 --- a/tests/integration/rename_branch_test.go +++ b/tests/integration/rename_branch_test.go @@ -11,7 +11,7 @@ import ( git_model "forgejo.org/models/git" repo_model "forgejo.org/models/repo" "forgejo.org/models/unittest" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/tests" "github.com/stretchr/testify/assert" @@ -105,7 +105,7 @@ func testRenameBranch(t *testing.T, u *url.URL) { "to": "branch1", }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "error") @@ -133,7 +133,7 @@ func testRenameBranch(t *testing.T, u *url.URL) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie = session.GetCookie(gitea_context.CookieNameFlash) + flashCookie = session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success") @@ -163,7 +163,7 @@ func testRenameBranch(t *testing.T, u *url.URL) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "error%3DCannot%2Brename%2Bbranch%2Bmain2%2Bbecause%2Bit%2Bis%2Ba%2Bprotected%2Bbranch.", flashCookie.Value) diff --git a/tests/integration/repo_settings_test.go b/tests/integration/repo_settings_test.go index 6b467d78b2..e3a1dede4d 100644 --- a/tests/integration/repo_settings_test.go +++ b/tests/integration/repo_settings_test.go @@ -16,7 +16,7 @@ import ( user_model "forgejo.org/models/user" "forgejo.org/modules/optional" "forgejo.org/modules/setting" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" repo_service "forgejo.org/services/repository" user_service "forgejo.org/services/user" "forgejo.org/tests" @@ -298,7 +298,7 @@ func TestProtectedBranch(t *testing.T) { "require_signed_": "true", }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Equal(t, "error%3DThere%2Bis%2Balready%2Ba%2Brule%2Bfor%2Bthis%2Bset%2Bof%2Bbranches", flashCookie.Value) diff --git a/tests/integration/repo_webhook_test.go b/tests/integration/repo_webhook_test.go index ffddd47faa..aa2d7538a1 100644 --- a/tests/integration/repo_webhook_test.go +++ b/tests/integration/repo_webhook_test.go @@ -9,7 +9,7 @@ import ( "net/url" "testing" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/webhook" "forgejo.org/tests" @@ -447,7 +447,7 @@ func assertHasFlashMessages(t *testing.T, resp *httptest.ResponseRecorder, expec seenKeys := make(map[string][]string, len(expectedKeys)) for _, cookie := range resp.Result().Cookies() { - if cookie.Name != gitea_context.CookieNameFlash { + if cookie.Name != app_context.CookieNameFlash { continue } flash, _ := url.ParseQuery(cookie.Value) diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index fd5c85e970..0e993636c7 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -26,7 +26,7 @@ import ( api "forgejo.org/modules/structs" "forgejo.org/modules/test" "forgejo.org/modules/translation" - gitea_context "forgejo.org/services/context" + app_context "forgejo.org/services/context" "forgejo.org/services/mailer" "forgejo.org/tests" @@ -917,7 +917,7 @@ func TestUserTOTPReenroll(t *testing.T) { }) session.MakeRequest(t, req, http.StatusSeeOther) - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) assert.Contains(t, flashCookie.Value, "success%3DYour%2Baccount%2Bhas%2Bbeen%2Bsuccessfully%2Benrolled.") } @@ -945,7 +945,7 @@ func TestUserTOTPDisable(t *testing.T) { session.MakeRequest(t, req, status) } if flashMessage != "" { - flashCookie := session.GetCookie(gitea_context.CookieNameFlash) + flashCookie := session.GetCookie(app_context.CookieNameFlash) assert.NotNil(t, flashCookie) if disableAllowed { assert.Contains(t, flashCookie.Value, fmt.Sprintf("success%%3D%s", flashMessage))