Skip to content

Commit cd76c70

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Add missing repository type filter parameters to pager (go-gitea#31832) Fix panic of ssh public key page after deletion of auth source (go-gitea#31829) [skip ci] Updated translations via Crowdin render plain text file if the LFS object doesn't exist (go-gitea#31812)
2 parents 5a422db + e4f850b commit cd76c70

File tree

15 files changed

+100
-21
lines changed

15 files changed

+100
-21
lines changed

models/asymkey/ssh_key.go

Lines changed: 7 additions & 16 deletions
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

Lines changed: 10 additions & 0 deletions
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+
}

options/locale/locale_ja-JP.ini

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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"`

routers/web/explore/repo.go

Lines changed: 15 additions & 0 deletions
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

Lines changed: 16 additions & 0 deletions
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/view.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,12 @@ func getFileReader(ctx gocontext.Context, repoID int64, blob *git.Blob) ([]byte,
234234
}
235235

236236
meta, err := git_model.GetLFSMetaObjectByOid(ctx, repoID, pointer.Oid)
237-
if err != nil && err != git_model.ErrLFSObjectNotExist { // fallback to plain file
237+
if err != nil { // fallback to plain file
238+
log.Warn("Unable to access LFS pointer %s in repo %d: %v", pointer.Oid, repoID, err)
238239
return buf, dataRc, &fileInfo{isTextFile, false, blob.Size(), nil, st}, nil
239240
}
240241

241242
dataRc.Close()
242-
if err != nil {
243-
return nil, nil, nil, err
244-
}
245243

246244
dataRc, err = lfs.ReadMetaObject(pointer)
247245
if err != nil {

routers/web/user/notification.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,21 @@ func NotificationWatching(ctx *context.Context) {
446446
// redirect to last page if request page is more than total pages
447447
pager := context.NewPagination(total, setting.UI.User.RepoPagingNum, page, 5)
448448
pager.SetDefaultParams(ctx)
449+
if archived.Has() {
450+
pager.AddParamString("archived", fmt.Sprint(archived.Value()))
451+
}
452+
if fork.Has() {
453+
pager.AddParamString("fork", fmt.Sprint(fork.Value()))
454+
}
455+
if mirror.Has() {
456+
pager.AddParamString("mirror", fmt.Sprint(mirror.Value()))
457+
}
458+
if template.Has() {
459+
pager.AddParamString("template", fmt.Sprint(template.Value()))
460+
}
461+
if private.Has() {
462+
pager.AddParamString("private", fmt.Sprint(private.Value()))
463+
}
449464
ctx.Data["Page"] = pager
450465

451466
ctx.Data["Status"] = 2

routers/web/user/profile.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,21 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
333333
pager.AddParamString("date", fmt.Sprint(ctx.Data["Date"]))
334334
}
335335
}
336+
if archived.Has() {
337+
pager.AddParamString("archived", fmt.Sprint(archived.Value()))
338+
}
339+
if fork.Has() {
340+
pager.AddParamString("fork", fmt.Sprint(fork.Value()))
341+
}
342+
if mirror.Has() {
343+
pager.AddParamString("mirror", fmt.Sprint(mirror.Value()))
344+
}
345+
if template.Has() {
346+
pager.AddParamString("template", fmt.Sprint(template.Value()))
347+
}
348+
if private.Has() {
349+
pager.AddParamString("private", fmt.Sprint(private.Value()))
350+
}
336351
ctx.Data["Page"] = pager
337352
}
338353

tests/gitea-repositories-meta/user2/lfs.git/objects/30/77e1c4c8964613df72c37d14275c1eda5228a9

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xK��OR0�0`p�� �t
2+
��s��MQH��)I-��I+VH�LK3rS��S�,ݒԊ.-���t"U&e��23�,1'�8���A�
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
73cf03db6ece34e12bf91e8853dc58f678f2f82d
1+
e9c32647bab825977942598c0efa415de300304b

tests/integration/lfs_view_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ func TestLFSRender(t *testing.T) {
8989
content := doc.Find("div.file-view").Text()
9090
assert.Contains(t, content, "Testing READMEs in LFS")
9191
})
92+
93+
// check that an invalid lfs entry defaults to plaintext
94+
t.Run("Invalid", func(t *testing.T) {
95+
defer tests.PrintCurrentTest(t)()
96+
97+
req := NewRequest(t, "GET", "/user2/lfs/src/branch/master/invalid")
98+
resp := session.MakeRequest(t, req, http.StatusOK)
99+
100+
doc := NewHTMLParser(t, resp.Body).doc
101+
102+
content := doc.Find("div.file-view").Text()
103+
assert.Contains(t, content, "oid sha256:9d178b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351")
104+
})
92105
}
93106

94107
// TestLFSLockView tests the LFS lock view on settings page of repositories

0 commit comments

Comments
 (0)