mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-17 00:01:00 -04:00
Compare commits
12 Commits
3ff81d38d8
...
79f7329971
Author | SHA1 | Date | |
---|---|---|---|
|
79f7329971 | ||
|
a625f3a761 | ||
|
5743d7cb5b | ||
|
9881b8a4e2 | ||
|
04771b5ff7 | ||
|
02efd99010 | ||
|
327a7ad518 | ||
|
4ab8e56c91 | ||
|
9eb4a9e601 | ||
|
f01bed2443 | ||
|
e8aae43f56 | ||
|
fcb4941d47 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -75,6 +75,7 @@ cpu.out
|
||||
/public/assets/js
|
||||
/public/assets/css
|
||||
/public/assets/fonts
|
||||
/public/assets/licenses.txt
|
||||
/public/assets/img/webpack
|
||||
/vendor
|
||||
/web_src/fomantic/node_modules
|
||||
|
@ -4,29 +4,18 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// GetQueryBeforeSince return parsed time (unix format) from URL query's before and since
|
||||
func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) {
|
||||
qCreatedBefore, err := prepareQueryArg(ctx, "before")
|
||||
before, err = parseFormTime(ctx, "before")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
qCreatedSince, err := prepareQueryArg(ctx, "since")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
before, err = parseTime(qCreatedBefore)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
since, err = parseTime(qCreatedSince)
|
||||
since, err = parseFormTime(ctx, "since")
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
@ -34,7 +23,8 @@ func GetQueryBeforeSince(ctx *Base) (before, since int64, err error) {
|
||||
}
|
||||
|
||||
// parseTime parse time and return unix timestamp
|
||||
func parseTime(value string) (int64, error) {
|
||||
func parseFormTime(ctx *Base, name string) (int64, error) {
|
||||
value := strings.TrimSpace(ctx.FormString(name))
|
||||
if len(value) != 0 {
|
||||
t, err := time.Parse(time.RFC3339, value)
|
||||
if err != nil {
|
||||
@ -46,10 +36,3 @@ func parseTime(value string) (int64, error) {
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// prepareQueryArg unescape and trim a query arg
|
||||
func prepareQueryArg(ctx *Base, name string) (value string, err error) {
|
||||
value, err = url.PathUnescape(ctx.FormString(name))
|
||||
value = strings.TrimSpace(value)
|
||||
return value, err
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package test
|
||||
// Package contexttest provides utilities for testing Web/API contexts with models.
|
||||
package contexttest
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
@ -22,7 +23,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/translation"
|
||||
"code.gitea.io/gitea/modules/web/middleware"
|
||||
|
||||
chi "github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -40,7 +41,6 @@ func mockRequest(t *testing.T, reqPath string) *http.Request {
|
||||
}
|
||||
|
||||
// MockContext mock context for unit tests
|
||||
// TODO: move this function to other packages, because it depends on "models" package
|
||||
func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.ResponseRecorder) {
|
||||
resp := httptest.NewRecorder()
|
||||
req := mockRequest(t, reqPath)
|
||||
@ -50,7 +50,6 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp
|
||||
base.Locale = &translation.MockLocale{}
|
||||
|
||||
ctx := context.NewWebContext(base, &MockRender{}, nil)
|
||||
ctx.Flash = &middleware.Flash{Values: url.Values{}}
|
||||
|
||||
chiCtx := chi.NewRouteContext()
|
||||
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
@ -58,7 +57,6 @@ func MockContext(t *testing.T, reqPath string) (*context.Context, *httptest.Resp
|
||||
}
|
||||
|
||||
// MockAPIContext mock context for unit tests
|
||||
// TODO: move this function to other packages, because it depends on "models" package
|
||||
func MockAPIContext(t *testing.T, reqPath string) (*context.APIContext, *httptest.ResponseRecorder) {
|
||||
resp := httptest.NewRecorder()
|
||||
req := mockRequest(t, reqPath)
|
||||
@ -123,7 +121,7 @@ func LoadRepoCommit(t *testing.T, ctx gocontext.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// LoadUser load a user into a test context.
|
||||
// LoadUser load a user into a test context
|
||||
func LoadUser(t *testing.T, ctx gocontext.Context, userID int64) {
|
||||
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: userID})
|
||||
switch ctx := ctx.(type) {
|
@ -191,6 +191,12 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if cert.CertType != gossh.UserCert {
|
||||
log.Warn("Certificate Rejected: Not a user certificate")
|
||||
log.Warn("Failed authentication attempt from %s", ctx.RemoteAddr())
|
||||
return false
|
||||
}
|
||||
|
||||
// look for the exact principal
|
||||
principalLoop:
|
||||
for _, principal := range cert.ValidPrincipals {
|
||||
|
@ -379,6 +379,7 @@ email_not_associate = The email address is not associated with any account.
|
||||
send_reset_mail = Send Account Recovery Email
|
||||
reset_password = Account Recovery
|
||||
invalid_code = Your confirmation code is invalid or has expired.
|
||||
invalid_code_forgot_password = Your confirmation code is invalid or has expired. Click <a href="%s">here</a> to start a new session.
|
||||
invalid_password = Your password does not match the password that was used to create the account.
|
||||
reset_password_helper = Recover Account
|
||||
reset_password_wrong_user = You are signed in as %s, but the account recovery link is meant for %s
|
||||
|
@ -12,4 +12,4 @@ djlint = "1.32.1"
|
||||
|
||||
[tool.djlint]
|
||||
profile="golang"
|
||||
ignore="H005,H006,H008,H013,H016,H020,H021,H030,H031"
|
||||
ignore="H005,H006,H013,H016,H020,H021,H030,H031"
|
||||
|
@ -935,7 +935,8 @@ func Routes() *web.Route {
|
||||
}, reqToken())
|
||||
m.Group("/actions/secrets", func() {
|
||||
m.Combo("/{secretname}").
|
||||
Put(reqToken(), reqOwner(), bind(api.CreateOrUpdateSecretOption{}), repo.CreateOrUpdateSecret)
|
||||
Put(reqToken(), reqOwner(), bind(api.CreateOrUpdateSecretOption{}), repo.CreateOrUpdateSecret).
|
||||
Delete(reqToken(), reqOwner(), repo.DeleteSecret)
|
||||
})
|
||||
m.Group("/hooks/git", func() {
|
||||
m.Combo("").Get(repo.ListGitHooks)
|
||||
@ -1306,7 +1307,7 @@ func Routes() *web.Route {
|
||||
m.Get("", reqToken(), reqOrgOwnership(), org.ListActionsSecrets)
|
||||
m.Combo("/{secretname}").
|
||||
Put(reqToken(), reqOrgOwnership(), bind(api.CreateOrUpdateSecretOption{}), org.CreateOrUpdateSecret).
|
||||
Delete(reqToken(), reqOrgOwnership(), org.DeleteOrgSecret)
|
||||
Delete(reqToken(), reqOrgOwnership(), org.DeleteSecret)
|
||||
})
|
||||
m.Group("/public_members", func() {
|
||||
m.Get("", org.ListPublicMembers)
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -34,7 +34,7 @@ func testRenderMarkup(t *testing.T, mode, filePath, text, responseBody string, r
|
||||
Wiki: true,
|
||||
FilePath: filePath,
|
||||
}
|
||||
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markup")
|
||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markup")
|
||||
web.SetForm(ctx, &options)
|
||||
Markup(ctx)
|
||||
assert.Equal(t, responseBody, resp.Body.String())
|
||||
@ -50,7 +50,7 @@ func testRenderMarkdown(t *testing.T, mode, text, responseBody string, responseC
|
||||
Context: Repo,
|
||||
Wiki: true,
|
||||
}
|
||||
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
web.SetForm(ctx, &options)
|
||||
Markdown(ctx)
|
||||
assert.Equal(t, responseBody, resp.Body.String())
|
||||
@ -162,7 +162,7 @@ func TestAPI_RenderSimple(t *testing.T) {
|
||||
Text: "",
|
||||
Context: Repo,
|
||||
}
|
||||
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
for i := 0; i < len(simpleCases); i += 2 {
|
||||
options.Text = simpleCases[i]
|
||||
web.SetForm(ctx, &options)
|
||||
@ -174,7 +174,7 @@ func TestAPI_RenderSimple(t *testing.T) {
|
||||
|
||||
func TestAPI_RenderRaw(t *testing.T) {
|
||||
setting.AppURL = AppURL
|
||||
ctx, resp := test.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
ctx, resp := contexttest.MockAPIContext(t, "POST /api/v1/markdown")
|
||||
for i := 0; i < len(simpleCases); i += 2 {
|
||||
ctx.Req.Body = io.NopCloser(strings.NewReader(simpleCases[i]))
|
||||
MarkdownRaw(ctx)
|
||||
|
@ -125,8 +125,8 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// DeleteOrgSecret delete one secret of the organization
|
||||
func DeleteOrgSecret(ctx *context.APIContext) {
|
||||
// DeleteSecret delete one secret of the organization
|
||||
func DeleteSecret(ctx *context.APIContext) {
|
||||
// swagger:operation DELETE /orgs/{org}/actions/secrets/{secretname} organization deleteOrgSecret
|
||||
// ---
|
||||
// summary: Delete a secret in an organization
|
||||
@ -151,6 +151,10 @@ func DeleteOrgSecret(ctx *context.APIContext) {
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
secretName := ctx.Params(":secretname")
|
||||
if err := actions.NameRegexMatch(secretName); err != nil {
|
||||
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
|
||||
return
|
||||
}
|
||||
err := secret_model.DeleteSecret(
|
||||
ctx, ctx.Org.Organization.ID, 0, secretName,
|
||||
)
|
||||
|
@ -73,3 +73,57 @@ func CreateOrUpdateSecret(ctx *context.APIContext) {
|
||||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// DeleteSecret delete one secret of the repository
|
||||
func DeleteSecret(ctx *context.APIContext) {
|
||||
// swagger:operation DELETE /repos/{owner}/{repo}/actions/secrets/{secretname} repository deleteRepoSecret
|
||||
// ---
|
||||
// summary: Delete a secret in a repository
|
||||
// consumes:
|
||||
// - application/json
|
||||
// produces:
|
||||
// - application/json
|
||||
// parameters:
|
||||
// - name: owner
|
||||
// in: path
|
||||
// description: owner of the repository
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: repo
|
||||
// in: path
|
||||
// description: name of the repository
|
||||
// type: string
|
||||
// required: true
|
||||
// - name: secretname
|
||||
// in: path
|
||||
// description: name of the secret
|
||||
// type: string
|
||||
// required: true
|
||||
// responses:
|
||||
// "204":
|
||||
// description: delete one secret of the organization
|
||||
// "403":
|
||||
// "$ref": "#/responses/forbidden"
|
||||
|
||||
owner := ctx.Repo.Owner
|
||||
repo := ctx.Repo.Repository
|
||||
|
||||
secretName := ctx.Params(":secretname")
|
||||
if err := actions.NameRegexMatch(secretName); err != nil {
|
||||
ctx.Error(http.StatusBadRequest, "DeleteSecret", err)
|
||||
return
|
||||
}
|
||||
err := secret_model.DeleteSecret(
|
||||
ctx, owner.ID, repo.ID, secretName,
|
||||
)
|
||||
if secret_model.IsErrSecretNotFound(err) {
|
||||
ctx.NotFound(err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "DeleteSecret", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/models/webhook"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -17,11 +17,11 @@ import (
|
||||
func TestTestHook(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockAPIContext(t, "user2/repo1/wiki/_pages")
|
||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
TestHook(ctx)
|
||||
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
|
||||
|
||||
|
@ -344,7 +344,7 @@ func getIssueAttachmentSafeRead(ctx *context.APIContext, issue *issues_model.Iss
|
||||
}
|
||||
|
||||
func canUserWriteIssueAttachment(ctx *context.APIContext, issue *issues_model.Issue) bool {
|
||||
canEditIssue := ctx.IsSigned && (ctx.Doer.ID == issue.PosterID || ctx.IsUserRepoAdmin() || ctx.IsUserSiteAdmin()) && ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
||||
canEditIssue := ctx.IsSigned && (ctx.Doer.ID == issue.PosterID || ctx.IsUserRepoAdmin() || ctx.IsUserSiteAdmin() || ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull))
|
||||
if !canEditIssue {
|
||||
ctx.Error(http.StatusForbidden, "", "user should have permission to write issue")
|
||||
return false
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -19,9 +19,9 @@ import (
|
||||
func TestRepoEdit(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockAPIContext(t, "user2/repo1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Repo.Owner = ctx.Doer
|
||||
description := "new description"
|
||||
website := "http://wwww.newwebsite.com"
|
||||
@ -65,9 +65,9 @@ func TestRepoEdit(t *testing.T) {
|
||||
func TestRepoEditNameChange(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockAPIContext(t, "user2/repo1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockAPIContext(t, "user2/repo1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Repo.Owner = ctx.Doer
|
||||
name := "newname"
|
||||
opts := api.EditRepoOption{
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
@ -19,7 +19,7 @@ import (
|
||||
|
||||
func TestNewUserPost_MustChangePassword(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
||||
|
||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
IsAdmin: true,
|
||||
@ -56,7 +56,7 @@ func TestNewUserPost_MustChangePassword(t *testing.T) {
|
||||
|
||||
func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
||||
|
||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
IsAdmin: true,
|
||||
@ -93,7 +93,7 @@ func TestNewUserPost_MustChangePasswordFalse(t *testing.T) {
|
||||
|
||||
func TestNewUserPost_InvalidEmail(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
||||
|
||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
IsAdmin: true,
|
||||
@ -123,7 +123,7 @@ func TestNewUserPost_InvalidEmail(t *testing.T) {
|
||||
|
||||
func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
||||
|
||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
IsAdmin: true,
|
||||
@ -161,7 +161,7 @@ func TestNewUserPost_VisibilityDefaultPublic(t *testing.T) {
|
||||
|
||||
func TestNewUserPost_VisibilityPrivate(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "admin/users/new")
|
||||
ctx, _ := contexttest.MockContext(t, "admin/users/new")
|
||||
|
||||
u := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||
IsAdmin: true,
|
||||
|
@ -5,6 +5,7 @@ package auth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"code.gitea.io/gitea/models/auth"
|
||||
@ -108,14 +109,14 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
|
||||
}
|
||||
|
||||
if len(code) == 0 {
|
||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code"))
|
||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code_forgot_password", fmt.Sprintf("%s/user/forgot_password", setting.AppSubURL)), true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Fail early, don't frustrate the user
|
||||
u := user_model.VerifyUserActiveCode(code)
|
||||
if u == nil {
|
||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code"))
|
||||
ctx.Flash.Error(ctx.Tr("auth.invalid_code_forgot_password", fmt.Sprintf("%s/user/forgot_password", setting.AppSubURL)), true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -134,7 +135,7 @@ func commonResetPassword(ctx *context.Context) (*user_model.User, *auth.TwoFacto
|
||||
ctx.Data["user_email"] = u.Email
|
||||
|
||||
if nil != ctx.Doer && u.ID != ctx.Doer.ID {
|
||||
ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.Doer.Email, u.Email))
|
||||
ctx.Flash.Error(ctx.Tr("auth.reset_password_wrong_user", ctx.Doer.Email, u.Email), true)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/routers/web/org"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -15,8 +15,8 @@ import (
|
||||
|
||||
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/-/projects/4/4")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/-/projects/4/4")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.ContextUser = ctx.Doer // user2
|
||||
ctx.SetParams(":id", "4")
|
||||
ctx.SetParams(":boardID", "4")
|
||||
|
@ -7,8 +7,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -41,12 +41,12 @@ func TestCleanUploadName(t *testing.T) {
|
||||
|
||||
func TestGetUniquePatchBranchName(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
expectedBranchName := "user2-patch-1"
|
||||
@ -56,12 +56,12 @@ func TestGetUniquePatchBranchName(t *testing.T) {
|
||||
|
||||
func TestGetClosestParentWithFiles(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/repository"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
@ -32,9 +33,9 @@ func int64SliceToCommaSeparated(a []int64) string {
|
||||
func TestInitializeLabels(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
assert.NoError(t, repository.LoadRepoConfig())
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/labels/initialize")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/initialize")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 2)
|
||||
web.SetForm(ctx, &forms.InitializeLabelsForm{TemplateName: "Default"})
|
||||
InitializeLabels(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
@ -57,9 +58,9 @@ func TestRetrieveLabels(t *testing.T) {
|
||||
{1, "leastissues", []int64{2, 1}},
|
||||
{2, "", []int64{}},
|
||||
} {
|
||||
ctx, _ := test.MockContext(t, "user/repo/issues")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, testCase.RepoID)
|
||||
ctx, _ := contexttest.MockContext(t, "user/repo/issues")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, testCase.RepoID)
|
||||
ctx.Req.Form.Set("sort", testCase.Sort)
|
||||
RetrieveLabels(ctx)
|
||||
assert.False(t, ctx.Written())
|
||||
@ -75,9 +76,9 @@ func TestRetrieveLabels(t *testing.T) {
|
||||
|
||||
func TestNewLabel(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/labels/edit")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/edit")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
web.SetForm(ctx, &forms.CreateLabelForm{
|
||||
Title: "newlabel",
|
||||
Color: "#abcdef",
|
||||
@ -93,9 +94,9 @@ func TestNewLabel(t *testing.T) {
|
||||
|
||||
func TestUpdateLabel(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/labels/edit")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/edit")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
web.SetForm(ctx, &forms.CreateLabelForm{
|
||||
ID: 2,
|
||||
Title: "newnameforlabel",
|
||||
@ -114,9 +115,9 @@ func TestUpdateLabel(t *testing.T) {
|
||||
|
||||
func TestDeleteLabel(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/labels/delete")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/labels/delete")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
ctx.Req.Form.Set("id", "2")
|
||||
DeleteLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
@ -127,9 +128,9 @@ func TestDeleteLabel(t *testing.T) {
|
||||
|
||||
func TestUpdateIssueLabel_Clear(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
ctx.Req.Form.Set("issue_ids", "1,3")
|
||||
ctx.Req.Form.Set("action", "clear")
|
||||
UpdateIssueLabel(ctx)
|
||||
@ -152,9 +153,9 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) {
|
||||
{"toggle", []int64{1, 2}, 2, true},
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
ctx.Req.Form.Set("issue_ids", int64SliceToCommaSeparated(testCase.IssueIDs))
|
||||
ctx.Req.Form.Set("action", testCase.Action)
|
||||
ctx.Req.Form.Set("id", strconv.Itoa(int(testCase.LabelID)))
|
||||
|
@ -7,16 +7,16 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCheckProjectBoardChangePermissions(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/projects/1/2")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/projects/1/2")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
ctx.SetParams(":id", "1")
|
||||
ctx.SetParams(":boardID", "2")
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
@ -47,10 +47,10 @@ func TestNewReleasePost(t *testing.T) {
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/releases/new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/releases/new")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
web.SetForm(ctx, &testCase.Form)
|
||||
NewReleasePost(ctx)
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Release{
|
||||
@ -67,10 +67,10 @@ func TestNewReleasePost(t *testing.T) {
|
||||
|
||||
func TestNewReleasesList(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo-release/releases")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 57)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo-release/releases")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 57)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
t.Cleanup(func() { ctx.Repo.GitRepo.Close() })
|
||||
|
||||
Releases(ctx)
|
||||
|
@ -15,8 +15,8 @@ import (
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
@ -42,10 +42,10 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
|
||||
}
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys")
|
||||
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 2)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 2)
|
||||
|
||||
addKeyForm := forms.AddKeyForm{
|
||||
Title: "read-only",
|
||||
@ -71,10 +71,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
||||
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/settings/keys")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/settings/keys")
|
||||
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 2)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 2)
|
||||
|
||||
addKeyForm := forms.AddKeyForm{
|
||||
Title: "read-write",
|
||||
@ -94,10 +94,10 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
||||
|
||||
func TestCollaborationPost(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 4)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadUser(t, ctx, 4)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
|
||||
ctx.Req.Form.Set("collaborator", "user4")
|
||||
|
||||
@ -129,10 +129,10 @@ func TestCollaborationPost(t *testing.T) {
|
||||
|
||||
func TestCollaborationPost_InactiveUser(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 9)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadUser(t, ctx, 9)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
|
||||
ctx.Req.Form.Set("collaborator", "user9")
|
||||
|
||||
@ -152,10 +152,10 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
|
||||
|
||||
func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadUser(t, ctx, 4)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadUser(t, ctx, 4)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
|
||||
ctx.Req.Form.Set("collaborator", "user4")
|
||||
|
||||
@ -193,9 +193,9 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
||||
|
||||
func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/issues/labels")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/issues/labels")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
|
||||
ctx.Req.Form.Set("collaborator", "user34")
|
||||
|
||||
@ -215,7 +215,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
||||
|
||||
func TestAddTeamPost(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
||||
|
||||
ctx.Req.Form.Set("team", "team11")
|
||||
|
||||
@ -255,7 +255,7 @@ func TestAddTeamPost(t *testing.T) {
|
||||
|
||||
func TestAddTeamPost_NotAllowed(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
||||
|
||||
ctx.Req.Form.Set("team", "team11")
|
||||
|
||||
@ -295,7 +295,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
|
||||
|
||||
func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
||||
|
||||
ctx.Req.Form.Set("team", "team11")
|
||||
|
||||
@ -336,7 +336,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
||||
|
||||
func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "org26/repo43")
|
||||
ctx, _ := contexttest.MockContext(t, "org26/repo43")
|
||||
|
||||
ctx.Req.Form.Set("team", "team-non-existent")
|
||||
|
||||
@ -369,7 +369,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
||||
|
||||
func TestDeleteTeam(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "org3/team1/repo3")
|
||||
ctx, _ := contexttest.MockContext(t, "org3/team1/repo3")
|
||||
|
||||
ctx.Req.Form.Set("id", "2")
|
||||
|
||||
|
@ -11,8 +11,8 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
wiki_service "code.gitea.io/gitea/services/wiki"
|
||||
@ -78,9 +78,9 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas any) {
|
||||
func TestWiki(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||
ctx.SetParams("*", "Home")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
Wiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||
@ -90,8 +90,8 @@ func TestWiki(t *testing.T) {
|
||||
func TestWikiPages(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
WikiPages(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assertPagesMetas(t, []string{"Home", "Page With Image", "Page With Spaced Name", "Unescaped File"}, ctx.Data["Pages"])
|
||||
@ -100,9 +100,9 @@ func TestWikiPages(t *testing.T) {
|
||||
func TestNewWiki(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
NewWiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
|
||||
@ -115,9 +115,9 @@ func TestNewWikiPost(t *testing.T) {
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
web.SetForm(ctx, &forms.NewWikiForm{
|
||||
Title: title,
|
||||
Content: content,
|
||||
@ -133,9 +133,9 @@ func TestNewWikiPost(t *testing.T) {
|
||||
func TestNewWikiPost_ReservedName(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_new")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
web.SetForm(ctx, &forms.NewWikiForm{
|
||||
Title: "_edit",
|
||||
Content: content,
|
||||
@ -150,10 +150,10 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
|
||||
func TestEditWiki(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_edit")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_edit")
|
||||
ctx.SetParams("*", "Home")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
EditWiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||
@ -166,10 +166,10 @@ func TestEditWikiPost(t *testing.T) {
|
||||
"New/<page>",
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_new")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_new")
|
||||
ctx.SetParams("*", "Home")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
web.SetForm(ctx, &forms.NewWikiForm{
|
||||
Title: title,
|
||||
Content: content,
|
||||
@ -188,9 +188,9 @@ func TestEditWikiPost(t *testing.T) {
|
||||
func TestDeleteWikiPagePost(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/Home?action=_delete")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/Home?action=_delete")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
DeleteWikiPagePost(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
|
||||
@ -207,10 +207,10 @@ func TestWikiRaw(t *testing.T) {
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
ctx, _ := test.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath))
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/raw/"+url.PathEscape(filepath))
|
||||
ctx.SetParams("*", filepath)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
WikiRaw(ctx)
|
||||
if filetype == "" {
|
||||
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -20,8 +20,8 @@ func TestArchivedIssues(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx, _ := test.MockContext(t, "issues")
|
||||
test.LoadUser(t, ctx, 30)
|
||||
ctx, _ := contexttest.MockContext(t, "issues")
|
||||
contexttest.LoadUser(t, ctx, 30)
|
||||
ctx.Req.Form.Set("state", "open")
|
||||
|
||||
// Assume: User 30 has access to two Repos with Issues, one of the Repos being archived.
|
||||
@ -53,8 +53,8 @@ func TestIssues(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx, _ := test.MockContext(t, "issues")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "issues")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Req.Form.Set("state", "closed")
|
||||
Issues(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
@ -69,8 +69,8 @@ func TestPulls(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 20
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx, _ := test.MockContext(t, "pulls")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "pulls")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Req.Form.Set("state", "open")
|
||||
Pulls(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
@ -82,8 +82,8 @@ func TestMilestones(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx, _ := test.MockContext(t, "milestones")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "milestones")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.SetParams("sort", "issues")
|
||||
ctx.Req.Form.Set("state", "closed")
|
||||
ctx.Req.Form.Set("sort", "furthestduedate")
|
||||
@ -101,8 +101,8 @@ func TestMilestonesForSpecificRepo(t *testing.T) {
|
||||
setting.UI.IssuePagingNum = 1
|
||||
assert.NoError(t, unittest.LoadFixtures())
|
||||
|
||||
ctx, _ := test.MockContext(t, "milestones")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
ctx, _ := contexttest.MockContext(t, "milestones")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.SetParams("sort", "issues")
|
||||
ctx.SetParams("repo", "1")
|
||||
ctx.Req.Form.Set("state", "closed")
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/web"
|
||||
"code.gitea.io/gitea/services/forms"
|
||||
|
||||
@ -83,9 +83,9 @@ func TestChangePassword(t *testing.T) {
|
||||
t.Run(req.OldPassword+"__"+req.NewPassword, func(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
setting.PasswordComplexity = req.PasswordComplexity
|
||||
ctx, _ := test.MockContext(t, "user/settings/security")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
ctx, _ := contexttest.MockContext(t, "user/settings/security")
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
|
||||
web.SetForm(ctx, &forms.ChangePasswordForm{
|
||||
OldPassword: req.OldPassword,
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/models/user"
|
||||
gitea_context "code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -42,7 +42,7 @@ func TestProcessorHelper(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
base, baseCleanUp := gitea_context.NewBaseContext(httptest.NewRecorder(), req)
|
||||
defer baseCleanUp()
|
||||
giteaCtx := gitea_context.NewWebContext(base, &test.MockRender{}, nil)
|
||||
giteaCtx := gitea_context.NewWebContext(base, &contexttest.MockRender{}, nil)
|
||||
|
||||
assert.True(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPublic))
|
||||
assert.False(t, ProcessorHelper().IsUsernameMentionable(giteaCtx, userPrivate))
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -24,11 +24,11 @@ func TestMain(m *testing.M) {
|
||||
func TestArchive_Basic(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
ctx, _ := test.MockContext(t, "user27/repo49")
|
||||
ctx, _ := contexttest.MockContext(t, "user27/repo49")
|
||||
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
||||
|
||||
test.LoadRepo(t, ctx, 49)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 49)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
bogusReq, err := NewRequest(ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit+".zip")
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -54,12 +54,12 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
|
||||
|
||||
func TestGetContents(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "README.md"
|
||||
@ -82,12 +82,12 @@ func TestGetContents(t *testing.T) {
|
||||
|
||||
func TestGetContentsOrListForDir(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "" // root dir
|
||||
@ -117,12 +117,12 @@ func TestGetContentsOrListForDir(t *testing.T) {
|
||||
|
||||
func TestGetContentsOrListForFile(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
treePath := "README.md"
|
||||
@ -145,12 +145,12 @@ func TestGetContentsOrListForFile(t *testing.T) {
|
||||
|
||||
func TestGetContentsErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -176,12 +176,12 @@ func TestGetContentsErrors(t *testing.T) {
|
||||
|
||||
func TestGetContentsOrListErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -207,11 +207,11 @@ func TestGetContentsOrListErrors(t *testing.T) {
|
||||
|
||||
func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user30/empty")
|
||||
ctx, _ := contexttest.MockContext(t, "user30/empty")
|
||||
ctx.SetParams(":id", "52")
|
||||
test.LoadRepo(t, ctx, 52)
|
||||
test.LoadUser(t, ctx, 30)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 52)
|
||||
contexttest.LoadUser(t, ctx, 30)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -225,11 +225,11 @@ func TestGetContentsOrListOfEmptyRepos(t *testing.T) {
|
||||
|
||||
func TestGetBlobBySHA(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
sha := "65f1bf27bc3bf70f64657658635e66094edbcb4d"
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/services/gitdiff"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -17,12 +17,12 @@ import (
|
||||
|
||||
func TestGetDiffPreview(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
branch := ctx.Repo.Repository.DefaultBranch
|
||||
@ -139,12 +139,12 @@ func TestGetDiffPreview(t *testing.T) {
|
||||
|
||||
func TestGetDiffPreviewErrors(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
branch := ctx.Repo.Repository.DefaultBranch
|
||||
|
@ -7,10 +7,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@ -98,12 +98,12 @@ func getExpectedFileResponse() *api.FileResponse {
|
||||
|
||||
func TestGetFileResponseFromCommit(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
|
@ -7,19 +7,19 @@ import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetTreeBySHA(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
sha := ctx.Repo.Repository.DefaultBranch
|
||||
|
@ -23,7 +23,7 @@
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
<a href="{{AssetUrlPrefix}}/js/licenses.txt">{{.locale.Tr "licenses"}}</a>
|
||||
<a href="{{AssetUrlPrefix}}/licenses.txt">{{.locale.Tr "licenses"}}</a>
|
||||
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
|
||||
{{template "custom/extra_links_footer" .}}
|
||||
</div>
|
||||
|
@ -25,42 +25,7 @@
|
||||
.ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
|
||||
</style>
|
||||
</noscript>
|
||||
{{if .PageIsUserProfile}}
|
||||
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
||||
<meta property="og:type" content="profile">
|
||||
<meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}">
|
||||
<meta property="og:url" content="{{.ContextUser.HTMLURL}}">
|
||||
{{if .ContextUser.Description}}
|
||||
<meta property="og:description" content="{{.ContextUser.Description}}">
|
||||
{{end}}
|
||||
{{else if .Repository}}
|
||||
{{if .Issue}}
|
||||
<meta property="og:title" content="{{.Issue.Title}}">
|
||||
<meta property="og:url" content="{{.Issue.HTMLURL}}">
|
||||
{{if .Issue.Content}}
|
||||
<meta property="og:description" content="{{.Issue.Content}}">
|
||||
{{end}}
|
||||
{{else}}
|
||||
<meta property="og:title" content="{{.Repository.Name}}">
|
||||
<meta property="og:url" content="{{.Repository.HTMLURL}}">
|
||||
{{if .Repository.Description}}
|
||||
<meta property="og:description" content="{{.Repository.Description}}">
|
||||
{{end}}
|
||||
{{end}}
|
||||
<meta property="og:type" content="object">
|
||||
{{if (.Repository.AvatarLink ctx)}}
|
||||
<meta property="og:image" content="{{.Repository.AvatarLink ctx}}">
|
||||
{{else}}
|
||||
<meta property="og:image" content="{{.Repository.Owner.AvatarLink ctx}}">
|
||||
{{end}}
|
||||
{{else}}
|
||||
<meta property="og:title" content="{{AppName}}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
|
||||
<meta property="og:url" content="{{AppUrl}}">
|
||||
<meta property="og:description" content="{{MetaDescription}}">
|
||||
{{end}}
|
||||
<meta property="og:site_name" content="{{AppName}}">
|
||||
{{template "base/head_opengraph" .}}
|
||||
{{template "base/head_style" .}}
|
||||
{{template "custom/header" .}}
|
||||
</head>
|
||||
|
42
templates/base/head_opengraph.tmpl
Normal file
42
templates/base/head_opengraph.tmpl
Normal file
@ -0,0 +1,42 @@
|
||||
{{if .PageIsUserProfile}}
|
||||
<meta property="og:title" content="{{.ContextUser.DisplayName}}">
|
||||
<meta property="og:type" content="profile">
|
||||
<meta property="og:image" content="{{.ContextUser.AvatarLink ctx}}">
|
||||
<meta property="og:url" content="{{.ContextUser.HTMLURL}}">
|
||||
{{if .ContextUser.Description}}
|
||||
<meta property="og:description" content="{{.ContextUser.Description}}">
|
||||
{{end}}
|
||||
{{else if .Repository}}
|
||||
{{if .Issue}}
|
||||
<meta property="og:title" content="{{.Issue.Title}}">
|
||||
<meta property="og:url" content="{{.Issue.HTMLURL}}">
|
||||
{{if .Issue.Content}}
|
||||
<meta property="og:description" content="{{.Issue.Content}}">
|
||||
{{end}}
|
||||
{{else if or .PageIsDiff .IsViewFile}}
|
||||
<meta property="og:title" content="{{.Title}}">
|
||||
<meta property="og:url" content="{{AppUrl}}{{.Link}}">
|
||||
{{if and .PageIsDiff (IsMultilineCommitMessage .Commit.Message)}}
|
||||
<meta property="og:description" content="{{RenderCommitBody $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}">
|
||||
{{end}}
|
||||
{{else}}
|
||||
<meta property="og:title" content="{{.Repository.Name}}">
|
||||
<meta property="og:url" content="{{.Repository.HTMLURL}}">
|
||||
{{if .Repository.Description}}
|
||||
<meta property="og:description" content="{{.Repository.Description}}">
|
||||
{{end}}
|
||||
{{end}}
|
||||
<meta property="og:type" content="object">
|
||||
{{if (.Repository.AvatarLink ctx)}}
|
||||
<meta property="og:image" content="{{.Repository.AvatarLink ctx}}">
|
||||
{{else}}
|
||||
<meta property="og:image" content="{{.Repository.Owner.AvatarLink ctx}}">
|
||||
{{end}}
|
||||
{{else}}
|
||||
<meta property="og:title" content="{{AppName}}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="{{AssetUrlPrefix}}/img/logo.png">
|
||||
<meta property="og:url" content="{{AppUrl}}">
|
||||
<meta property="og:description" content="{{MetaDescription}}">
|
||||
{{end}}
|
||||
<meta property="og:site_name" content="{{AppName}}">
|
@ -6,7 +6,7 @@
|
||||
{{- range .Attachments -}}
|
||||
<div class="gt-df">
|
||||
<div class="gt-f1 gt-p-3">
|
||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title="{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}">
|
||||
{{if FilenameIsImage .Name}}
|
||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||
{{$hasThumbnails = true}}
|
||||
@ -31,7 +31,7 @@
|
||||
{{if FilenameIsImage .Name}}
|
||||
{{if not (StringUtils.Contains $.Content .UUID)}}
|
||||
<a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}">
|
||||
<img alt="{{.Name}}" src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'>
|
||||
<img alt="{{.Name}}" src="{{.DownloadURL}}" title="{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}">
|
||||
</a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
@ -111,9 +111,9 @@
|
||||
{{template "shared/user/authorlink" .Poster}}
|
||||
{{$link := printf "%s/commit/%s" $.Repository.Link ($.Issue.PullRequest.MergedCommitID|PathEscape)}}
|
||||
{{if eq $.Issue.PullRequest.Status 3}}
|
||||
{{$.locale.Tr "repo.issues.comment_manually_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.comment_manually_pull_merged_at" (printf `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||
{{else}}
|
||||
{{$.locale.Tr "repo.issues.comment_pull_merged_at" (printf "<a class='ui sha' href='%[1]s'><b>%[2]s</b></a>" ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||
{{$.locale.Tr "repo.issues.comment_pull_merged_at" (printf `<a class="ui sha" href="%[1]s"><b>%[2]s</b></a>` ($link|Escape) (ShortSha $.Issue.PullRequest.MergedCommitID)) (printf "<b>%[1]s</b>" ($.BaseTarget|Escape)) $createdStr | Safe}}
|
||||
{{end}}
|
||||
</span>
|
||||
</div>
|
||||
|
44
templates/swagger/v1_json.tmpl
generated
44
templates/swagger/v1_json.tmpl
generated
@ -3287,6 +3287,50 @@
|
||||
"$ref": "#/responses/forbidden"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"repository"
|
||||
],
|
||||
"summary": "Delete a secret in a repository",
|
||||
"operationId": "deleteRepoSecret",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "owner of the repository",
|
||||
"name": "owner",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the repository",
|
||||
"name": "repo",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "name of the secret",
|
||||
"name": "secretname",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "delete one secret of the organization"
|
||||
},
|
||||
"403": {
|
||||
"$ref": "#/responses/forbidden"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/repos/{owner}/{repo}/activities/feeds": {
|
||||
|
@ -57,7 +57,7 @@
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<p class="center">{{.locale.Tr "auth.invalid_code"}}</p>
|
||||
<p class="center">{{.locale.Tr "auth.invalid_code_forgot_password" (printf "%s/user/forgot_password" AppSubUrl) | Str2html}}</p>
|
||||
{{end}}
|
||||
</div>
|
||||
</form>
|
||||
|
@ -97,7 +97,7 @@
|
||||
</a>
|
||||
{{end}}
|
||||
<div class="item">
|
||||
<a class="ui primary basic button" href="{{.ContextUser.HomeLink}}" title='{{.locale.Tr "home.view_home" .ContextUser.Name}}'>
|
||||
<a class="ui primary basic button" href="{{.ContextUser.HomeLink}}" title="{{.locale.Tr "home.view_home" .ContextUser.Name}}">
|
||||
{{.locale.Tr "home.view_home" (.ContextUser.ShortName 40)}}
|
||||
</a>
|
||||
</div>
|
||||
|
@ -15,7 +15,7 @@
|
||||
<form action="{{AppSubUrl}}/notifications/purge" method="post">
|
||||
{{$.CsrfTokenHtml}}
|
||||
<div class="{{if not $notificationUnreadCount}}gt-hidden{{end}}">
|
||||
<button class="ui mini button primary gt-mr-0" title='{{$.locale.Tr "notification.mark_all_as_read"}}'>
|
||||
<button class="ui mini button primary gt-mr-0" title="{{$.locale.Tr "notification.mark_all_as_read"}}">
|
||||
{{svg "octicon-checklist"}}
|
||||
</button>
|
||||
</div>
|
||||
@ -74,7 +74,7 @@
|
||||
{{$.CsrfTokenHtml}}
|
||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||
<input type="hidden" name="status" value="pinned">
|
||||
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.pin"}}'
|
||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.pin"}}"
|
||||
data-url="{{AppSubUrl}}/notifications/status"
|
||||
data-status="pinned"
|
||||
data-page="{{$.Page.Paginater.Current}}"
|
||||
@ -90,7 +90,7 @@
|
||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||
<input type="hidden" name="status" value="read">
|
||||
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
||||
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.mark_as_read"}}'
|
||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.mark_as_read"}}"
|
||||
data-url="{{AppSubUrl}}/notifications/status"
|
||||
data-status="read"
|
||||
data-page="{{$.Page.Paginater.Current}}"
|
||||
@ -105,7 +105,7 @@
|
||||
<input type="hidden" name="notification_id" value="{{.ID}}">
|
||||
<input type="hidden" name="status" value="unread">
|
||||
<input type="hidden" name="page" value="{{$.Page.Paginater.Current}}">
|
||||
<button class="btn interact-bg gt-p-3" title='{{$.locale.Tr "notification.mark_as_unread"}}'
|
||||
<button class="btn interact-bg gt-p-3" title="{{$.locale.Tr "notification.mark_as_unread"}}"
|
||||
data-url="{{AppSubUrl}}/notifications/status"
|
||||
data-status="unread"
|
||||
data-page="{{$.Page.Paginater.Current}}"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="ui secondary stackable pointing menu">
|
||||
{{if .HasProfileReadme}}
|
||||
<a class='{{if eq .TabName "overview"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=overview">
|
||||
<a class="{{if eq .TabName "overview"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=overview">
|
||||
{{svg "octicon-info"}} {{.locale.Tr "user.overview"}}
|
||||
</a>
|
||||
{{end}}
|
||||
@ -50,18 +50,18 @@
|
||||
</div>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<a class='{{if eq .TabName "activity"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=activity">
|
||||
<a class="{{if eq .TabName "activity"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=activity">
|
||||
{{svg "octicon-rss"}} {{.locale.Tr "user.activity"}}
|
||||
</a>
|
||||
{{if not .DisableStars}}
|
||||
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars">
|
||||
<a class="{{if eq .TabName "stars"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=stars">
|
||||
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
|
||||
{{if .ContextUser.NumStars}}
|
||||
<div class="ui small label">{{.ContextUser.NumStars}}</div>
|
||||
{{end}}
|
||||
</a>
|
||||
{{else}}
|
||||
<a class='{{if eq .TabName "watching"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=watching">
|
||||
<a class="{{if eq .TabName "watching"}}active {{end}}item" href="{{.ContextUser.HomeLink}}?tab=watching">
|
||||
{{svg "octicon-eye"}} {{.locale.Tr "user.watched"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
@ -234,7 +234,7 @@ func TestAPISearchIssues(t *testing.T) {
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||
since := "2000-01-01T00:50:01+00:00" // 946687801
|
||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||
query.Add("since", since)
|
||||
query.Add("before", before)
|
||||
|
@ -368,7 +368,7 @@ func TestSearchIssues(t *testing.T) {
|
||||
DecodeJSON(t, resp, &apiIssues)
|
||||
assert.Len(t, apiIssues, expectedIssueCount)
|
||||
|
||||
since := "2000-01-01T00%3A50%3A01%2B00%3A00" // 946687801
|
||||
since := "2000-01-01T00:50:01+00:00" // 946687801
|
||||
before := time.Unix(999307200, 0).Format(time.RFC3339)
|
||||
query := url.Values{}
|
||||
query.Add("since", since)
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
"code.gitea.io/gitea/modules/contexttest"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
files_service "code.gitea.io/gitea/services/repository/files"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -245,12 +245,12 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA
|
||||
func TestChangeRepoFilesForCreate(t *testing.T) {
|
||||
// setup
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -282,12 +282,12 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
|
||||
func TestChangeRepoFilesForUpdate(t *testing.T) {
|
||||
// setup
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -316,12 +316,12 @@ func TestChangeRepoFilesForUpdate(t *testing.T) {
|
||||
func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
||||
// setup
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -367,12 +367,12 @@ func TestChangeRepoFilesForUpdateWithFileMove(t *testing.T) {
|
||||
func TestChangeRepoFilesWithoutBranchNames(t *testing.T) {
|
||||
// setup
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -403,12 +403,12 @@ func TestChangeRepoFilesForDelete(t *testing.T) {
|
||||
func testDeleteRepoFiles(t *testing.T, u *url.URL) {
|
||||
// setup
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
repo := ctx.Repo.Repository
|
||||
doer := ctx.Doer
|
||||
@ -442,12 +442,12 @@ func TestChangeRepoFilesForDeleteWithoutBranchNames(t *testing.T) {
|
||||
func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
||||
// setup
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
@ -472,12 +472,12 @@ func testDeleteRepoFilesWithoutBranchNames(t *testing.T, u *url.URL) {
|
||||
func TestChangeRepoFilesErrors(t *testing.T) {
|
||||
// setup
|
||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
||||
ctx, _ := test.MockContext(t, "user2/repo1")
|
||||
ctx, _ := contexttest.MockContext(t, "user2/repo1")
|
||||
ctx.SetParams(":id", "1")
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
test.LoadRepoCommit(t, ctx)
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadGitRepo(t, ctx)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadGitRepo(t, ctx)
|
||||
defer ctx.Repo.GitRepo.Close()
|
||||
|
||||
repo := ctx.Repo.Repository
|
||||
|
@ -245,6 +245,7 @@
|
||||
--color-tooltip-bg: #000000f0;
|
||||
--color-nav-bg: #ffffff;
|
||||
--color-nav-hover-bg: #ebebeb;
|
||||
--color-nav-text: var(--color-text);
|
||||
--color-label-text: #232323;
|
||||
--color-label-bg: #cacaca5b;
|
||||
--color-label-hover-bg: #cacacaa0;
|
||||
@ -1647,10 +1648,6 @@ img.ui.avatar,
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
i.icons .icon:first-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.ui.label {
|
||||
padding: 0.3em 0.5em;
|
||||
transition: none;
|
||||
@ -1686,14 +1683,6 @@ a.ui.active.label:hover {
|
||||
color: var(--color-label-text);
|
||||
}
|
||||
|
||||
.ui.label > .detail .icons {
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
|
||||
.ui.label > .detail .icons .icon {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.lines-blame-btn {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
@ -2099,6 +2088,7 @@ table th[data-sortt-desc] .svg {
|
||||
vertical-align: -0.15em;
|
||||
}
|
||||
|
||||
/* for the jquery.minicolors plugin */
|
||||
.minicolors-panel {
|
||||
background: var(--color-secondary-dark-1) !important;
|
||||
}
|
||||
|
@ -34,6 +34,10 @@
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#navbar > .menu > .item {
|
||||
color: var(--color-nav-text);
|
||||
}
|
||||
|
||||
#navbar .dropdown .item {
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
border-radius: var(--border-radius);
|
||||
background: transparent;
|
||||
border: none;
|
||||
display: inline-block;
|
||||
display: flex;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
|
@ -41,10 +41,10 @@ const filterCssImport = (url, ...args) => {
|
||||
|
||||
if (cssFile.includes('fomantic')) {
|
||||
if (/brand-icons/.test(importedFile)) return false;
|
||||
if (/(eot|ttf|otf|woff|svg)$/.test(importedFile)) return false;
|
||||
if (/(eot|ttf|otf|woff|svg)$/i.test(importedFile)) return false;
|
||||
}
|
||||
|
||||
if (cssFile.includes('katex') && /(ttf|woff)$/.test(importedFile)) {
|
||||
if (cssFile.includes('katex') && /(ttf|woff)$/i.test(importedFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -117,12 +117,12 @@ export default {
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.vue$/,
|
||||
test: /\.vue$/i,
|
||||
exclude: /node_modules/,
|
||||
loader: 'vue-loader',
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
test: /\.js$/i,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
@ -151,12 +151,12 @@ export default {
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.svg$/,
|
||||
test: /\.svg$/i,
|
||||
include: fileURLToPath(new URL('public/assets/img/svg', import.meta.url)),
|
||||
type: 'asset/source',
|
||||
},
|
||||
{
|
||||
test: /\.(ttf|woff2?)$/,
|
||||
test: /\.(ttf|woff2?)$/i,
|
||||
type: 'asset/resource',
|
||||
generator: {
|
||||
filename: 'fonts/[name].[contenthash:8][ext]',
|
||||
@ -188,7 +188,7 @@ export default {
|
||||
filename: 'js/monaco-[name].[contenthash:8].worker.js',
|
||||
}),
|
||||
isProduction ? new LicenseCheckerWebpackPlugin({
|
||||
outputFilename: 'js/licenses.txt',
|
||||
outputFilename: 'licenses.txt',
|
||||
outputWriter: ({dependencies}) => {
|
||||
const line = '-'.repeat(80);
|
||||
const goJson = readFileSync('assets/go-licenses.json', 'utf8');
|
||||
@ -211,7 +211,7 @@ export default {
|
||||
},
|
||||
emitError: true,
|
||||
allow: '(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT OR ISC OR CPAL-1.0 OR Unlicense OR EPL-1.0 OR EPL-2.0)',
|
||||
}) : new AddAssetPlugin('js/licenses.txt', `Licenses are disabled during development`),
|
||||
}) : new AddAssetPlugin('licenses.txt', `Licenses are disabled during development`),
|
||||
],
|
||||
performance: {
|
||||
hints: false,
|
||||
@ -239,7 +239,7 @@ export default {
|
||||
entrypoints: false,
|
||||
excludeAssets: [
|
||||
/^js\/monaco-language-.+\.js$/,
|
||||
!isProduction && /^js\/licenses.txt$/,
|
||||
!isProduction && /^licenses.txt$/,
|
||||
].filter(Boolean),
|
||||
groupAssetsByChunk: false,
|
||||
groupAssetsByEmitStatus: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user