Skip to content

Commit c39643f

Browse files
committed
fghfghf
1 parent 38a09ea commit c39643f

21 files changed

+209
-79
lines changed

New Text Document.txt

Whitespace-only changes.

models/asymkey/ssh_key.go

+7-16
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,26 @@ func UpdatePublicKeyUpdated(ctx context.Context, id int64) error {
229229

230230
// PublicKeysAreExternallyManaged returns whether the provided KeyID represents an externally managed Key
231231
func PublicKeysAreExternallyManaged(ctx context.Context, keys []*PublicKey) ([]bool, error) {
232-
sources := make([]*auth.Source, 0, 5)
232+
sourceCache := make(map[int64]*auth.Source, len(keys))
233233
externals := make([]bool, len(keys))
234-
keyloop:
234+
235235
for i, key := range keys {
236236
if key.LoginSourceID == 0 {
237237
externals[i] = false
238-
continue keyloop
239-
}
240-
241-
var source *auth.Source
242-
243-
sourceloop:
244-
for _, s := range sources {
245-
if s.ID == key.LoginSourceID {
246-
source = s
247-
break sourceloop
248-
}
238+
continue
249239
}
250240

251-
if source == nil {
241+
source, ok := sourceCache[key.LoginSourceID]
242+
if !ok {
252243
var err error
253244
source, err = auth.GetSourceByID(ctx, key.LoginSourceID)
254245
if err != nil {
255246
if auth.IsErrSourceNotExist(err) {
256247
externals[i] = false
257-
sources[i] = &auth.Source{
248+
sourceCache[key.LoginSourceID] = &auth.Source{
258249
ID: key.LoginSourceID,
259250
}
260-
continue keyloop
251+
continue
261252
}
262253
return nil, err
263254
}

models/asymkey/ssh_key_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"strings"
1313
"testing"
1414

15+
"code.gitea.io/gitea/models/db"
16+
"code.gitea.io/gitea/models/unittest"
1517
"code.gitea.io/gitea/modules/setting"
1618

1719
"github.com/42wim/sshsig"
@@ -503,3 +505,11 @@ func runErr(t *testing.T, stdin []byte, args ...string) {
503505
t.Fatal("expected error")
504506
}
505507
}
508+
509+
func Test_PublicKeysAreExternallyManaged(t *testing.T) {
510+
key1 := unittest.AssertExistsAndLoadBean(t, &PublicKey{ID: 1})
511+
externals, err := PublicKeysAreExternallyManaged(db.DefaultContext, []*PublicKey{key1})
512+
assert.NoError(t, err)
513+
assert.Len(t, externals, 1)
514+
assert.False(t, externals[0])
515+
}

modules/markup/html_link.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
package markup
55

66
import (
7-
"path"
8-
97
"code.gitea.io/gitea/modules/util"
108
)
119

@@ -14,13 +12,9 @@ func ResolveLink(ctx *RenderContext, link, userContentAnchorPrefix string) (resu
1412
if !isAnchorFragment && !IsFullURLString(link) {
1513
linkBase := ctx.Links.Base
1614
if ctx.IsWiki {
17-
if ext := path.Ext(link); ext == "" || ext == ".-" {
18-
linkBase = ctx.Links.WikiLink() // the link is for a wiki page
19-
} else if DetectMarkupTypeByFileName(link) != "" {
20-
linkBase = ctx.Links.WikiLink() // the link is renderable as a wiki page
21-
} else {
22-
linkBase = ctx.Links.WikiRawLink() // otherwise, use a raw link instead to view&download medias
23-
}
15+
// no need to check if the link should be resolved as a wiki link or a wiki raw link
16+
// just use wiki link here and it will be redirected to a wiki raw link if necessary
17+
linkBase = ctx.Links.WikiLink()
2418
} else if ctx.Links.BranchPath != "" || ctx.Links.TreePath != "" {
2519
// if there is no BranchPath, then the link will be something like "/owner/repo/src/{the-file-path}"
2620
// and then this link will be handled by the "legacy-ref" code and be redirected to the default branch like "/owner/repo/src/branch/main/{the-file-path}"

modules/markup/html_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func TestRender_ShortLinks(t *testing.T) {
437437
renderableFileURL := util.URLJoin(tree, "markdown_file.md")
438438
renderableFileURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "markdown_file.md")
439439
unrenderableFileURL := util.URLJoin(tree, "file.zip")
440-
unrenderableFileURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "raw", "file.zip")
440+
unrenderableFileURLWiki := util.URLJoin(markup.TestRepoURL, "wiki", "file.zip")
441441
favicon := "http://google.com/favicon.ico"
442442

443443
test(

modules/markup/markdown/markdown_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ space</p>
672672
Expected: `<p>space @mention-user<br/>
673673
/just/a/path.bin<br/>
674674
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
675-
<a href="/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
675+
<a href="/wiki/file.bin" rel="nofollow">local link</a><br/>
676676
<a href="https://example.com" rel="nofollow">remote link</a><br/>
677-
<a href="/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
677+
<a href="/wiki/file.bin" rel="nofollow">local link</a><br/>
678678
<a href="https://example.com" rel="nofollow">remote link</a><br/>
679679
<a href="/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/wiki/raw/image.jpg" alt="local image"/></a><br/>
680680
<a href="/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/wiki/raw/path/file" alt="local image"/></a><br/>
@@ -730,9 +730,9 @@ space</p>
730730
Expected: `<p>space @mention-user<br/>
731731
/just/a/path.bin<br/>
732732
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
733-
<a href="https://gitea.io/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
733+
<a href="https://gitea.io/wiki/file.bin" rel="nofollow">local link</a><br/>
734734
<a href="https://example.com" rel="nofollow">remote link</a><br/>
735-
<a href="https://gitea.io/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
735+
<a href="https://gitea.io/wiki/file.bin" rel="nofollow">local link</a><br/>
736736
<a href="https://example.com" rel="nofollow">remote link</a><br/>
737737
<a href="https://gitea.io/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/wiki/raw/image.jpg" alt="local image"/></a><br/>
738738
<a href="https://gitea.io/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="https://gitea.io/wiki/raw/path/file" alt="local image"/></a><br/>
@@ -788,9 +788,9 @@ space</p>
788788
Expected: `<p>space @mention-user<br/>
789789
/just/a/path.bin<br/>
790790
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
791-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
791+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
792792
<a href="https://example.com" rel="nofollow">remote link</a><br/>
793-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
793+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
794794
<a href="https://example.com" rel="nofollow">remote link</a><br/>
795795
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
796796
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
@@ -848,9 +848,9 @@ space</p>
848848
Expected: `<p>space @mention-user<br/>
849849
/just/a/path.bin<br/>
850850
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
851-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
851+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
852852
<a href="https://example.com" rel="nofollow">remote link</a><br/>
853-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
853+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
854854
<a href="https://example.com" rel="nofollow">remote link</a><br/>
855855
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
856856
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
@@ -908,9 +908,9 @@ space</p>
908908
Expected: `<p>space @mention-user<br/>
909909
/just/a/path.bin<br/>
910910
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
911-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
911+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
912912
<a href="https://example.com" rel="nofollow">remote link</a><br/>
913-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
913+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
914914
<a href="https://example.com" rel="nofollow">remote link</a><br/>
915915
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
916916
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>
@@ -970,9 +970,9 @@ space</p>
970970
Expected: `<p>space @mention-user<br/>
971971
/just/a/path.bin<br/>
972972
<a href="https://example.com/file.bin" rel="nofollow">https://example.com/file.bin</a><br/>
973-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
973+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
974974
<a href="https://example.com" rel="nofollow">remote link</a><br/>
975-
<a href="/relative/path/wiki/raw/file.bin" rel="nofollow">local link</a><br/>
975+
<a href="/relative/path/wiki/file.bin" rel="nofollow">local link</a><br/>
976976
<a href="https://example.com" rel="nofollow">remote link</a><br/>
977977
<a href="/relative/path/wiki/raw/image.jpg" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/image.jpg" alt="local image"/></a><br/>
978978
<a href="/relative/path/wiki/raw/path/file" target="_blank" rel="nofollow noopener"><img src="/relative/path/wiki/raw/path/file" alt="local image"/></a><br/>

options/locale/locale_ja-JP.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,7 @@ issues.remove_labels=がラベル %s を除去 %s
14751475
issues.add_remove_labels=がラベル %s を追加、 %s を除去 %s
14761476
issues.add_milestone_at=`がマイルストーン <b>%[1]s</b> に追加 %[2]s`
14771477
issues.add_project_at=`がプロジェクト <b>%s</b> に追加 %s`
1478+
issues.move_to_column_of_project=`がこれを %[2]s の %[1]s に移動 %[3]s`
14781479
issues.change_milestone_at=`がマイルストーンを <b>%[1]s</b> から <b>%[2]s</b> へ変更 %[3]s`
14791480
issues.change_project_at=`がプロジェクトを <b>%s</b> から <b>%s</b> へ変更 %s`
14801481
issues.remove_milestone_at=`がマイルストーン <b>%[1]s</b> から除去 %[2]s`
@@ -1764,6 +1765,7 @@ compare.compare_head=比較
17641765
pulls.desc=プルリクエストとコードレビューの有効化。
17651766
pulls.new=新しいプルリクエスト
17661767
pulls.new.blocked_user=リポジトリのオーナーがあなたをブロックしているため、プルリクエストを作成できません。
1768+
pulls.new.must_collaborator=プルリクエストを作成するには、共同作業者である必要があります。
17671769
pulls.edit.already_changed=プルリクエストの変更を保存できません。 他のユーザーによって内容がすでに変更されているようです。 変更を上書きしないようにするため、ページを更新してからもう一度編集してください
17681770
pulls.view=プルリクエストを表示
17691771
pulls.compare_changes=新規プルリクエスト
@@ -1888,6 +1890,7 @@ pulls.cmd_instruction_checkout_title=チェックアウト
18881890
pulls.cmd_instruction_checkout_desc=プロジェクトリポジトリから新しいブランチをチェックアウトし、変更内容をテストします。
18891891
pulls.cmd_instruction_merge_title=マージ
18901892
pulls.cmd_instruction_merge_desc=変更内容をマージして、Giteaに反映します。
1893+
pulls.cmd_instruction_merge_warning=警告: 「手動マージの自動検出」が有効ではないため、この操作ではプルリクエストをマージできません
18911894
pulls.clear_merge_message=マージメッセージをクリア
18921895
pulls.clear_merge_message_hint=マージメッセージのクリアは、コミットメッセージの除去だけを行います。 生成されたGitトレーラー("Co-Authored-By …" 等)はそのまま残ります。
18931896

options/locale/locale_pt-PT.ini

+1
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,7 @@ settings.transfer_in_progress=Está a ser feita uma transferência. Cancele-a, p
21852185
settings.transfer_notices_1=- Você perderá o acesso ao repositório se o transferir para um utilizador individual.
21862186
settings.transfer_notices_2=- Você manterá o acesso ao repositório se o transferir para uma organização da qual você é (co-)proprietário(a).
21872187
settings.transfer_notices_3=- Se o repositório for privado e for transferido para um utilizador individual, esta operação certifica que o utilizador tem pelo menos a permissão de leitura (e altera as permissões se for necessário).
2188+
settings.transfer_notices_4=- se o repositório pertencer a uma organização e o transferir para outra organização ou indivíduo, irá perder as ligações entre as questões do repositório e o quadro de planeamento da organização.
21882189
settings.transfer_owner=Novo proprietário
21892190
settings.transfer_perform=Executar transferência
21902191
settings.transfer_started=`Este repositório foi marcado para ser transferido e aguarda a confirmação de "%s"`

package-lock.json

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"esbuild-loader": "4.2.2",
2929
"escape-goat": "4.0.0",
3030
"fast-glob": "3.3.2",
31-
"htmx.org": "2.0.0",
31+
"htmx.org": "2.0.2",
3232
"idiomorph": "0.3.0",
3333
"jquery": "3.7.1",
3434
"katex": "0.16.11",

routers/web/explore/repo.go

+15
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
144144
pager.AddParamString("topic", fmt.Sprint(topicOnly))
145145
pager.AddParamString("language", language)
146146
pager.AddParamString(relevantReposOnlyParam, fmt.Sprint(opts.OnlyShowRelevant))
147+
if archived.Has() {
148+
pager.AddParamString("archived", fmt.Sprint(archived.Value()))
149+
}
150+
if fork.Has() {
151+
pager.AddParamString("fork", fmt.Sprint(fork.Value()))
152+
}
153+
if mirror.Has() {
154+
pager.AddParamString("mirror", fmt.Sprint(mirror.Value()))
155+
}
156+
if template.Has() {
157+
pager.AddParamString("template", fmt.Sprint(template.Value()))
158+
}
159+
if private.Has() {
160+
pager.AddParamString("private", fmt.Sprint(private.Value()))
161+
}
147162
ctx.Data["Page"] = pager
148163

149164
ctx.HTML(http.StatusOK, opts.TplName)

routers/web/org/home.go

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package org
55

66
import (
7+
"fmt"
78
"net/http"
89
"path"
910
"strings"
@@ -155,6 +156,21 @@ func Home(ctx *context.Context) {
155156
pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
156157
pager.SetDefaultParams(ctx)
157158
pager.AddParamString("language", language)
159+
if archived.Has() {
160+
pager.AddParamString("archived", fmt.Sprint(archived.Value()))
161+
}
162+
if fork.Has() {
163+
pager.AddParamString("fork", fmt.Sprint(fork.Value()))
164+
}
165+
if mirror.Has() {
166+
pager.AddParamString("mirror", fmt.Sprint(mirror.Value()))
167+
}
168+
if template.Has() {
169+
pager.AddParamString("template", fmt.Sprint(template.Value()))
170+
}
171+
if private.Has() {
172+
pager.AddParamString("private", fmt.Sprint(private.Value()))
173+
}
158174
ctx.Data["Page"] = pager
159175

160176
ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0

routers/web/repo/pull.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,10 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13081308
// instead of 500.
13091309

13101310
if err := pull_service.NewPullRequest(ctx, repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil {
1311-
if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
1311+
switch {
1312+
case repo_model.IsErrUserDoesNotHaveAccessToRepo(err):
13121313
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())
1313-
} else if git.IsErrPushRejected(err) {
1314+
case git.IsErrPushRejected(err):
13141315
pushrejErr := err.(*git.ErrPushRejected)
13151316
message := pushrejErr.Message
13161317
if len(message) == 0 {
@@ -1327,7 +1328,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13271328
return
13281329
}
13291330
ctx.JSONError(flashError)
1330-
} else if errors.Is(err, user_model.ErrBlockedUser) {
1331+
case errors.Is(err, user_model.ErrBlockedUser):
13311332
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
13321333
"Message": ctx.Tr("repo.pulls.push_rejected"),
13331334
"Summary": ctx.Tr("repo.pulls.new.blocked_user"),
@@ -1337,7 +1338,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13371338
return
13381339
}
13391340
ctx.JSONError(flashError)
1340-
} else if errors.Is(err, issues_model.ErrMustCollaborator) {
1341+
case errors.Is(err, issues_model.ErrMustCollaborator):
13411342
flashError, err := ctx.RenderToHTML(tplAlertDetails, map[string]any{
13421343
"Message": ctx.Tr("repo.pulls.push_rejected"),
13431344
"Summary": ctx.Tr("repo.pulls.new.must_collaborator"),
@@ -1347,6 +1348,11 @@ func CompareAndPullRequestPost(ctx *context.Context) {
13471348
return
13481349
}
13491350
ctx.JSONError(flashError)
1351+
default:
1352+
// It's an unexpected error.
1353+
// If it happens, we should add another case to handle it.
1354+
log.Error("Unexpected error of NewPullRequest: %T %s", err, err)
1355+
ctx.ServerError("CompareAndPullRequest", err)
13501356
}
13511357
return
13521358
}

0 commit comments

Comments
 (0)