mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-17 11:59:30 +00:00
Merge branch 'forgejo' into feat/add-oidc-ssh-keys
This commit is contained in:
commit
8a3fb4885e
89 changed files with 4813 additions and 1391 deletions
|
@ -35,6 +35,7 @@ func Code(ctx *context.Context) {
|
|||
|
||||
language := ctx.FormTrim("l")
|
||||
keyword := ctx.FormTrim("q")
|
||||
path := ctx.FormTrim("path")
|
||||
|
||||
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)
|
||||
if mode := ctx.FormTrim("mode"); len(mode) > 0 {
|
||||
|
@ -91,6 +92,7 @@ func Code(ctx *context.Context) {
|
|||
Keyword: keyword,
|
||||
IsKeywordFuzzy: isFuzzy,
|
||||
Language: language,
|
||||
Filename: path,
|
||||
Paginator: &db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: setting.UI.RepoSearchPagingNum,
|
||||
|
|
|
@ -5,6 +5,7 @@ package actions
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
stdCtx "context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
|
@ -224,7 +225,7 @@ func List(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := loadIsRefDeleted(ctx, runs); err != nil {
|
||||
if err := loadIsRefDeleted(ctx, ctx.Repo.Repository.ID, runs); err != nil {
|
||||
log.Error("LoadIsRefDeleted", err)
|
||||
}
|
||||
|
||||
|
@ -254,7 +255,7 @@ func List(ctx *context.Context) {
|
|||
|
||||
// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
|
||||
// TODO: move this function to models/actions/run_list.go but now it will result in a circular import.
|
||||
func loadIsRefDeleted(ctx *context.Context, runs actions_model.RunList) error {
|
||||
func loadIsRefDeleted(ctx stdCtx.Context, repoID int64, runs actions_model.RunList) error {
|
||||
branches := make(container.Set[string], len(runs))
|
||||
for _, run := range runs {
|
||||
refName := git.RefName(run.Ref)
|
||||
|
@ -266,14 +267,14 @@ func loadIsRefDeleted(ctx *context.Context, runs actions_model.RunList) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
branchInfos, err := git_model.GetBranches(ctx, ctx.Repo.Repository.ID, branches.Values(), false)
|
||||
branchInfos, err := git_model.GetBranches(ctx, repoID, branches.Values(), false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
branchSet := git_model.BranchesToNamesSet(branchInfos)
|
||||
for _, run := range runs {
|
||||
refName := git.RefName(run.Ref)
|
||||
if refName.IsBranch() && !branchSet.Contains(run.Ref) {
|
||||
if refName.IsBranch() && !branchSet.Contains(refName.ShortName()) {
|
||||
run.IsRefDeleted = true
|
||||
}
|
||||
}
|
||||
|
|
33
routers/web/repo/actions/actions_test.go
Normal file
33
routers/web/repo/actions/actions_test.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package actions
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
actions_model "code.gitea.io/gitea/models/actions"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
unittest "code.gitea.io/gitea/models/unittest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func Test_loadIsRefDeleted(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
|
||||
runs, total, err := db.FindAndCount[actions_model.ActionRun](db.DefaultContext,
|
||||
actions_model.FindRunOptions{RepoID: 4, Ref: "refs/heads/test"})
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, runs, 1)
|
||||
assert.EqualValues(t, 1, total)
|
||||
for _, run := range runs {
|
||||
assert.False(t, run.IsRefDeleted)
|
||||
}
|
||||
|
||||
require.NoError(t, loadIsRefDeleted(db.DefaultContext, 4, runs))
|
||||
for _, run := range runs {
|
||||
assert.True(t, run.IsRefDeleted)
|
||||
}
|
||||
}
|
14
routers/web/repo/actions/main_test.go
Normal file
14
routers/web/repo/actions/main_test.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package actions
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
unittest.MainTest(m)
|
||||
}
|
|
@ -1918,6 +1918,21 @@ func ViewIssue(ctx *context.Context) {
|
|||
|
||||
ctx.Data["MergeStyle"] = mergeStyle
|
||||
|
||||
var updateStyle repo_model.UpdateStyle
|
||||
// Check correct values and select default
|
||||
if ms, ok := ctx.Data["UpdateStyle"].(repo_model.UpdateStyle); !ok ||
|
||||
!prConfig.IsUpdateStyleAllowed(ms) {
|
||||
defaultUpdateStyle := prConfig.GetDefaultUpdateStyle()
|
||||
if prConfig.IsUpdateStyleAllowed(defaultUpdateStyle) && !ok {
|
||||
updateStyle = defaultUpdateStyle
|
||||
} else if prConfig.AllowMerge {
|
||||
updateStyle = repo_model.UpdateStyleMerge
|
||||
} else if prConfig.AllowRebase {
|
||||
updateStyle = repo_model.UpdateStyleRebase
|
||||
}
|
||||
}
|
||||
ctx.Data["UpdateStyle"] = updateStyle
|
||||
|
||||
defaultMergeMessage, defaultMergeBody, err := pull_service.GetDefaultMergeMessage(ctx, ctx.Repo.GitRepo, pull, mergeStyle)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetDefaultMergeMessage", err)
|
||||
|
|
|
@ -54,6 +54,7 @@ func Search(ctx *context.Context) {
|
|||
language := ctx.FormTrim("l")
|
||||
keyword := ctx.FormTrim("q")
|
||||
|
||||
path := ctx.FormTrim("path")
|
||||
mode := ExactSearchMode
|
||||
if modeStr := ctx.FormString("mode"); len(modeStr) > 0 {
|
||||
mode = searchModeFromString(modeStr)
|
||||
|
@ -63,6 +64,7 @@ func Search(ctx *context.Context) {
|
|||
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
ctx.Data["CodeSearchPath"] = path
|
||||
ctx.Data["CodeSearchMode"] = mode.String()
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
|
||||
|
@ -86,6 +88,7 @@ func Search(ctx *context.Context) {
|
|||
Keyword: keyword,
|
||||
IsKeywordFuzzy: mode == FuzzySearchMode,
|
||||
Language: language,
|
||||
Filename: path,
|
||||
Paginator: &db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: setting.UI.RepoSearchPagingNum,
|
||||
|
@ -100,11 +103,12 @@ func Search(ctx *context.Context) {
|
|||
} else {
|
||||
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
|
||||
}
|
||||
ctx.Data["CodeSearchOptions"] = []string{"exact", "fuzzy"}
|
||||
ctx.Data["CodeSearchOptions"] = code_indexer.CodeSearchOptions
|
||||
} else {
|
||||
grepOpt := git.GrepOptions{
|
||||
ContextLineNumber: 1,
|
||||
RefName: ctx.Repo.RefName,
|
||||
Filename: path,
|
||||
}
|
||||
switch mode {
|
||||
case FuzzySearchMode:
|
||||
|
@ -130,10 +134,12 @@ func Search(ctx *context.Context) {
|
|||
// UpdatedUnix: not supported yet
|
||||
// Language: not supported yet
|
||||
// Color: not supported yet
|
||||
Lines: code_indexer.HighlightSearchResultCode(r.Filename, r.LineNumbers, r.HighlightedRanges, strings.Join(r.LineCodes, "\n")),
|
||||
Lines: code_indexer.HighlightSearchResultCode(
|
||||
r.Filename, r.LineNumbers, r.HighlightedRanges,
|
||||
strings.Join(r.LineCodes, "\n")),
|
||||
})
|
||||
}
|
||||
ctx.Data["CodeSearchOptions"] = []string{"exact", "union", "regexp"}
|
||||
ctx.Data["CodeSearchOptions"] = git.GrepSearchOptions
|
||||
}
|
||||
|
||||
ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled
|
||||
|
|
|
@ -262,6 +262,7 @@ func UnitsPost(ctx *context.Context) {
|
|||
AllowRebaseUpdate: form.PullsAllowRebaseUpdate,
|
||||
DefaultDeleteBranchAfterMerge: form.DefaultDeleteBranchAfterMerge,
|
||||
DefaultMergeStyle: repo_model.MergeStyle(form.PullsDefaultMergeStyle),
|
||||
DefaultUpdateStyle: repo_model.UpdateStyle(form.PullsDefaultUpdateStyle),
|
||||
DefaultAllowMaintainerEdit: form.DefaultAllowMaintainerEdit,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -39,6 +39,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/gitrepo"
|
||||
"code.gitea.io/gitea/modules/highlight"
|
||||
code_indexer "code.gitea.io/gitea/modules/indexer/code"
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
|
@ -1152,6 +1153,12 @@ PostRecentBranchCheck:
|
|||
ctx.Data["TreeNames"] = treeNames
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled
|
||||
if setting.Indexer.RepoIndexerEnabled {
|
||||
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
|
||||
ctx.Data["CodeSearchOptions"] = code_indexer.CodeSearchOptions
|
||||
} else {
|
||||
ctx.Data["CodeSearchOptions"] = git.GrepSearchOptions
|
||||
}
|
||||
ctx.HTML(http.StatusOK, tplRepoHome)
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ func CodeSearch(ctx *context.Context) {
|
|||
|
||||
language := ctx.FormTrim("l")
|
||||
keyword := ctx.FormTrim("q")
|
||||
path := ctx.FormTrim("path")
|
||||
|
||||
isFuzzy := ctx.FormOptionalBool("fuzzy").ValueOrDefault(true)
|
||||
if mode := ctx.FormTrim("mode"); len(mode) > 0 {
|
||||
|
@ -88,6 +89,7 @@ func CodeSearch(ctx *context.Context) {
|
|||
Keyword: keyword,
|
||||
IsKeywordFuzzy: isFuzzy,
|
||||
Language: language,
|
||||
Filename: path,
|
||||
Paginator: &db.ListOptions{
|
||||
Page: page,
|
||||
PageSize: setting.UI.RepoSearchPagingNum,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue