Skip to content

Commit 1b6e855

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Fix only text/* being viewable in web UI (go-gitea#34374) add maintainer tobiasbp (go-gitea#34372) [skip ci] Updated translations via Crowdin Use lfs label for lfs file rather than a long description (go-gitea#34363) Fix bug when API get pull changed files for deleted head repository (go-gitea#34333) Fix bug when visiting comparation page (go-gitea#34334) Fix LFS files being editable in web UI (go-gitea#34356) Bump `@github/relative-time-element` to v4.4.6 (go-gitea#34352) Fix repo search input height (go-gitea#34330) feat: return time of last usage for public keys and access tokens in the api (go-gitea#34323) fix: do not return archive download URLs in API if downloads are disabled (go-gitea#34324)
2 parents ed34981 + 12bf0b8 commit 1b6e855

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+170
-71
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ Rowan Bohde <[email protected]> (@bohde)
6464
hiifong <[email protected]> (@hiifong)
6565
metiftikci <[email protected]> (@metiftikci)
6666
Christopher Homberger <[email protected]> (@ChristopherHX)
67+
Tobias Balle-Petersen <[email protected]> (@tobiasbp)

modules/structs/repo_tag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type Tag struct {
1111
Message string `json:"message"`
1212
ID string `json:"id"`
1313
Commit *CommitMeta `json:"commit"`
14-
ZipballURL string `json:"zipball_url"`
15-
TarballURL string `json:"tarball_url"`
14+
ZipballURL string `json:"zipball_url,omitempty"`
15+
TarballURL string `json:"tarball_url,omitempty"`
1616
}
1717

1818
// AnnotatedTag represents an annotated tag

modules/structs/user_app.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import (
1111
// AccessToken represents an API access token.
1212
// swagger:response AccessToken
1313
type AccessToken struct {
14-
ID int64 `json:"id"`
15-
Name string `json:"name"`
16-
Token string `json:"sha1"`
17-
TokenLastEight string `json:"token_last_eight"`
18-
Scopes []string `json:"scopes"`
14+
ID int64 `json:"id"`
15+
Name string `json:"name"`
16+
Token string `json:"sha1"`
17+
TokenLastEight string `json:"token_last_eight"`
18+
Scopes []string `json:"scopes"`
19+
Created time.Time `json:"created_at"`
20+
Updated time.Time `json:"last_used_at"`
1921
}
2022

2123
// AccessTokenList represents a list of API access token.

modules/structs/user_key.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type PublicKey struct {
1616
Fingerprint string `json:"fingerprint,omitempty"`
1717
// swagger:strfmt date-time
1818
Created time.Time `json:"created_at,omitempty"`
19+
Updated time.Time `json:"last_used_at,omitempty"`
1920
Owner *User `json:"user,omitempty"`
2021
ReadOnly bool `json:"read_only,omitempty"`
2122
KeyType string `json:"key_type,omitempty"`

options/locale/locale_cs-CZ.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,6 @@ file_copy_permalink=Kopírovat trvalý odkaz
12851285
view_git_blame=Zobrazit Git Blame
12861286
video_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 video.
12871287
audio_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 audio.
1288-
stored_lfs=Uloženo pomocí Git LFS
12891288
symbolic_link=Symbolický odkaz
12901289
executable_file=Spustitelný soubor
12911290
vendored=Vendorováno

options/locale/locale_de-DE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,6 @@ file_copy_permalink=Permalink kopieren
12861286
view_git_blame=Git Blame ansehen
12871287
video_not_supported_in_browser=Dein Browser unterstützt das HTML5 'video'-Tag nicht.
12881288
audio_not_supported_in_browser=Dein Browser unterstützt den HTML5 'audio'-Tag nicht.
1289-
stored_lfs=Gespeichert mit Git LFS
12901289
symbolic_link=Softlink
12911290
executable_file=Ausführbare Datei
12921291
vendored=Vendor

options/locale/locale_el-GR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,6 @@ file_copy_permalink=Αντιγραφή Permalink
11481148
view_git_blame=Προβολή Git Blame
11491149
video_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'video'.
11501150
audio_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'audio'.
1151-
stored_lfs=Αποθηκεύτηκε με το Git LFS
11521151
symbolic_link=Symbolic link
11531152
executable_file=Εκτελέσιμο Αρχείο
11541153
commit_graph=Γράφημα Υποβολών

options/locale/locale_en-US.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@ file_copy_permalink = Copy Permalink
13051305
view_git_blame = View Git Blame
13061306
video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag.
13071307
audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag.
1308-
stored_lfs = Stored with Git LFS
13091308
symbolic_link = Symbolic link
13101309
executable_file = Executable File
13111310
vendored = Vendored

options/locale/locale_es-ES.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,6 @@ file_copy_permalink=Copiar Permalink
11381138
view_git_blame=Ver la culpa de Git
11391139
video_not_supported_in_browser=Su navegador no soporta el tag video de HTML5.
11401140
audio_not_supported_in_browser=Su navegador no soporta el tag audio de HTML5.
1141-
stored_lfs=Almacenados con Git LFS
11421141
symbolic_link=Enlace simbólico
11431142
executable_file=Archivo Ejecutable
11441143
commit_graph=Gráfico de commits

options/locale/locale_fa-IR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ file_too_large=حجم این پرونده بیشتر از آن است که قا
900900
file_copy_permalink=پرمالینک را کپی کنید
901901
video_not_supported_in_browser=مرورگر شما از تگ video که در HTML5 تعریف شده است، پشتیبانی نمی کند.
902902
audio_not_supported_in_browser=مرورگر شما از تگ audio که در HTML5 تعریف شده است، پشتیبانی نمی کند.
903-
stored_lfs=ذخیره شده با GIT LFS
904903
symbolic_link=پیوند نمادین
905904
commit_graph=نمودار کامیت
906905
commit_graph.select=انتخاب برنچها

options/locale/locale_fr-FR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,6 @@ file_copy_permalink=Copier le lien permanent
13041304
view_git_blame=Voir Git Blâme
13051305
video_not_supported_in_browser=Votre navigateur ne supporte pas la balise « vidéo » HTML5.
13061306
audio_not_supported_in_browser=Votre navigateur ne supporte pas la balise « audio » HTML5.
1307-
stored_lfs=Stocké avec Git LFS
13081307
symbolic_link=Lien symbolique
13091308
executable_file=Fichiers exécutables
13101309
vendored=Externe

options/locale/locale_ga-IE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@ file_copy_permalink=Cóipeáil Buan-nasc
13051305
view_git_blame=Féach ar Git Blame
13061306
video_not_supported_in_browser=Ní thacaíonn do bhrabhsálaí leis an gclib 'video' HTML5.
13071307
audio_not_supported_in_browser=Ní thacaíonn do bhrabhsálaí leis an gclib 'audio' HTML5.
1308-
stored_lfs=Stóráilte le Git LFS
13091308
symbolic_link=Nasc siombalach
13101309
executable_file=Comhad Infheidhmithe
13111310
vendored=Díoltóra

options/locale/locale_hu-HU.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,6 @@ file_too_large=Ez a fájl túl nagy ahhoz, hogy megjelenítsük.
679679

680680
video_not_supported_in_browser=A böngésző nem támogatja a HTML5 video tag-et.
681681
audio_not_supported_in_browser=A böngésző nem támogatja a HTML5 audio tag-et.
682-
stored_lfs=Git LFS-el eltárolva
683682
symbolic_link=Szimbolikus hivatkozás
684683
commit_graph=Commit gráf
685684
commit_graph.hide_pr_refs=Pull request-ek elrejtése

options/locale/locale_id-ID.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ file_view_raw=Lihat Mentah
685685
file_permalink=Permalink
686686
file_too_large=Berkas terlalu besar untuk ditampilkan.
687687

688-
stored_lfs=Tersimpan dengan GIT LFS
689688
commit_graph=Grafik Komit
690689
blame=Salahkan
691690
normal_view=Pandangan Normal

options/locale/locale_is-IS.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,6 @@ file_view_source=Skoða Frumkóða
667667
file_view_rendered=Skoða Unnið
668668

669669
file_copy_permalink=Afrita Varanlega Slóð
670-
stored_lfs=Geymt með Git LFS
671670
commit_graph.hide_pr_refs=Fela Sameiningarbeiðnir
672671
commit_graph.monochrome=Einlitað
673672
commit_graph.color=Litað

options/locale/locale_it-IT.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,6 @@ file_copy_permalink=Copia Permalink
967967
view_git_blame=Visualizza Git Blame
968968
video_not_supported_in_browser=Il tuo browser non supporta i tag "video" di HTML5.
969969
audio_not_supported_in_browser=Il tuo browser non supporta il tag "video" di HTML5.
970-
stored_lfs=Memorizzati con Git LFS
971970
symbolic_link=Link Simbolico
972971
commit_graph=Grafico dei commit
973972
commit_graph.select=Seleziona rami

options/locale/locale_ja-JP.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,6 @@ file_copy_permalink=パーマリンクをコピー
13041304
view_git_blame=Git Blameを表示
13051305
video_not_supported_in_browser=このブラウザはHTML5のvideoタグをサポートしていません。
13061306
audio_not_supported_in_browser=このブラウザーはHTML5のaudioタグをサポートしていません。
1307-
stored_lfs=Git LFSで保管されています
13081307
symbolic_link=シンボリック リンク
13091308
executable_file=実行ファイル
13101309
vendored=ベンダーファイル

options/locale/locale_ko-KR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,6 @@ file_too_large=보여주기에는 파일이 너무 큽니다.
626626

627627
video_not_supported_in_browser=당신의 브라우저가 HTML5 'video' 태그를 지원하지 않습니다.
628628
audio_not_supported_in_browser=당신의 브라우저가 HTML5 'audio' 태그를 지원하지 않습니다.
629-
stored_lfs=Git LFS에 저장되어 있습니다
630629
commit_graph=커밋 그래프
631630

632631
editor.new_file=새 파일

options/locale/locale_lv-LV.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,6 @@ file_copy_permalink=Kopēt saiti
11541154
view_git_blame=Aplūkot Git vainīgos
11551155
video_not_supported_in_browser=Jūsu pārlūks neatbalsta HTML5 video.
11561156
audio_not_supported_in_browser=Jūsu pārlūks neatbalsta HTML5 audio.
1157-
stored_lfs=Saglabāts Git LFS
11581157
symbolic_link=Simboliska saite
11591158
executable_file=Izpildāmais fails
11601159
commit_graph=Revīziju grafs

options/locale/locale_nl-NL.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,6 @@ file_copy_permalink=Permalink kopiëren
965965
view_git_blame=Bekijk Git Blame
966966
video_not_supported_in_browser=Je browser ondersteunt de HTML5 'video'-tag niet.
967967
audio_not_supported_in_browser=Je browser ondersteunt de HTML5 'audio'-tag niet.
968-
stored_lfs=Opgeslagen met Git LFS
969968
symbolic_link=Symbolic link
970969
commit_graph=Commit grafiek
971970
commit_graph.select=Selecteer branches

options/locale/locale_pl-PL.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ file_too_large=Ten plik jest zbyt duży, aby go wyświetlić.
900900
file_copy_permalink=Kopiuj bezpośredni odnośnik
901901
video_not_supported_in_browser=Twoja przeglądarka nie obsługuje znacznika HTML5 "video".
902902
audio_not_supported_in_browser=Twoja przeglądarka nie obsługuje znacznika HTML5 "audio".
903-
stored_lfs=Przechowane za pomocą Git LFS
904903
symbolic_link=Dowiązanie symboliczne
905904
commit_graph=Wykres commitów
906905
commit_graph.select=Wybierz gałęzie

options/locale/locale_pt-BR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,6 @@ file_copy_permalink=Copiar Link Permanente
11481148
view_git_blame=Ver Git Blame
11491149
video_not_supported_in_browser=Seu navegador não suporta a tag 'video' do HTML5.
11501150
audio_not_supported_in_browser=Seu navegador não suporta a tag 'audio' do HTML5.
1151-
stored_lfs=Armazenado com Git LFS
11521151
symbolic_link=Link simbólico
11531152
executable_file=Arquivo executável
11541153
generated=Gerado

options/locale/locale_pt-PT.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,6 @@ file_copy_permalink=Copiar ligação permanente
13051305
view_git_blame=Ver Git Blame
13061306
video_not_supported_in_browser=O seu navegador não suporta a etiqueta 'video' do HTML5.
13071307
audio_not_supported_in_browser=O seu navegador não suporta a etiqueta 'audio' do HTML5.
1308-
stored_lfs=Armazenado com Git LFS
13091308
symbolic_link=Ligação simbólica
13101309
executable_file=Ficheiro executável
13111310
vendored=Externo

options/locale/locale_ru-RU.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,6 @@ file_copy_permalink=Копировать постоянную ссылку
11271127
view_git_blame=Показать git blame
11281128
video_not_supported_in_browser=Ваш браузер не поддерживает HTML5 'video' тэг.
11291129
audio_not_supported_in_browser=Ваш браузер не поддерживает HTML5 'audio' тэг.
1130-
stored_lfs=Хранится Git LFS
11311130
symbolic_link=Символическая ссылка
11321131
executable_file=Исполняемый файл
11331132
commit_graph=Граф коммитов

options/locale/locale_si-LK.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,6 @@ file_too_large=ගොනුව පෙන්වීමට තරම් විශ
874874
file_copy_permalink=පිටපත් මාමලින්ක්
875875
video_not_supported_in_browser=ඔබගේ බ්රව්සරය HTML5 'වීඩියෝ' ටැගය සඳහා සහය නොදක්වයි.
876876
audio_not_supported_in_browser=ඔබගේ බ්රව්සරය HTML5 'ශ්රව්ය' ටැගය සඳහා සහය නොදක්වයි.
877-
stored_lfs=Git LFS සමඟ ගබඩා
878877
symbolic_link=සංකේතාත්මක සබැඳිය
879878
commit_graph=ප්රස්තාරය කැප
880879
commit_graph.select=ශාඛා තෝරන්න

options/locale/locale_sk-SK.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ file_copy_permalink=Kopírovať trvalý odkaz
981981
view_git_blame=Zobraziť Git Blame
982982
video_not_supported_in_browser=Váš prehliadač nepodporuje HTML5 tag 'video'.
983983
audio_not_supported_in_browser=Váš prehliadač nepodporuje HTML5 tag 'audio'.
984-
stored_lfs=Uložené pomocou Git LFS
985984
symbolic_link=Symbolický odkaz
986985
commit_graph=Graf commitov
987986
line=riadok

options/locale/locale_sv-SE.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ file_too_large=Filen är för stor för att visas.
739739

740740
video_not_supported_in_browser=Din webbläsare stödjer ej HTML5-taggen 'video'.
741741
audio_not_supported_in_browser=Din webbläsare stöder inte taggen 'audio' i HTML5.
742-
stored_lfs=Sparad med Git LFS
743742
symbolic_link=Symbolisk länk
744743
commit_graph=Commit-Graf
745744
commit_graph.monochrome=Mono

options/locale/locale_tr-TR.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,6 @@ file_copy_permalink=Kalıcı Bağlantıyı Kopyala
12441244
view_git_blame=Git Suç Görüntüle
12451245
video_not_supported_in_browser=Tarayıcınız HTML5 'video' etiketini desteklemiyor.
12461246
audio_not_supported_in_browser=Tarayıcınız HTML5 'audio' etiketini desteklemiyor.
1247-
stored_lfs=Git LFS ile depolandı
12481247
symbolic_link=Sembolik Bağlantı
12491248
executable_file=Çalıştırılabilir Dosya
12501249
vendored=Sağlanmış

options/locale/locale_uk-UA.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,6 @@ file_too_large=Цей файл завеликий щоб бути показан
910910
file_copy_permalink=Копіювати постійне посилання
911911
video_not_supported_in_browser=Ваш браузер не підтримує тег 'video' HTML5.
912912
audio_not_supported_in_browser=Ваш браузер не підтримує тег HTML5 'audio'.
913-
stored_lfs=Збережено з Git LFS
914913
symbolic_link=Символічне посилання
915914
commit_graph=Графік комітів
916915
commit_graph.select=Виберіть гілки

options/locale/locale_zh-CN.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,6 @@ file_copy_permalink=复制永久链接
13031303
view_git_blame=查看 Git Blame
13041304
video_not_supported_in_browser=您的浏览器不支持使用 HTML5 'video' 标签。
13051305
audio_not_supported_in_browser=您的浏览器不支持使用 HTML5 'video' 标签。
1306-
stored_lfs=存储到Git LFS
13071306
symbolic_link=符号链接
13081307
executable_file=可执行文件
13091308
vendored=被供应的

options/locale/locale_zh-HK.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ file_history=文件歷史
364364
file_view_raw=查看原始文件
365365
file_permalink=永久連結
366366

367-
stored_lfs=儲存到到 Git LFS
368367

369368
editor.preview_changes=預覽更改
370369
editor.or=或

options/locale/locale_zh-TW.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,6 @@ file_copy_permalink=複製固定連結
12731273
view_git_blame=檢視 Git Blame
12741274
video_not_supported_in_browser=您的瀏覽器不支援使用 HTML5 播放影片。
12751275
audio_not_supported_in_browser=您的瀏覽器不支援 HTML5 的「audio」標籤
1276-
stored_lfs=已使用 Git LFS 儲存
12771276
symbolic_link=符號連結
12781277
executable_file=可執行檔
12791278
vendored=已供應

package-lock.json

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@citation-js/plugin-csl": "0.7.18",
1010
"@citation-js/plugin-software-formats": "0.6.1",
1111
"@github/markdown-toolbar-element": "2.2.3",
12-
"@github/relative-time-element": "4.4.5",
12+
"@github/relative-time-element": "4.4.6",
1313
"@github/text-expander-element": "2.9.1",
1414
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1515
"@primer/octicons": "19.15.1",

routers/api/v1/repo/pull.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,9 @@ func GetPullRequestFiles(ctx *context.APIContext) {
16321632

16331633
apiFiles := make([]*api.ChangedFile, 0, limit)
16341634
for i := start; i < start+limit; i++ {
1635-
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.HeadRepo, endCommitID))
1635+
// refs/pull/1/head stores the HEAD commit ID, allowing all related commits to be found in the base repository.
1636+
// The head repository might have been deleted, so we should not rely on it here.
1637+
apiFiles = append(apiFiles, convert.ToChangedFile(diff.Files[i], pr.BaseRepo, endCommitID))
16361638
}
16371639

16381640
ctx.SetLinkHeader(totalNumberOfFiles, listOptions.PageSize)

routers/api/v1/user/app.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func ListAccessTokens(ctx *context.APIContext) {
6262
Name: tokens[i].Name,
6363
TokenLastEight: tokens[i].TokenLastEight,
6464
Scopes: tokens[i].Scope.StringSlice(),
65+
Created: tokens[i].CreatedUnix.AsTime(),
66+
Updated: tokens[i].UpdatedUnix.AsTime(),
6567
}
6668
}
6769

routers/web/repo/compare.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,11 @@ func ParseCompareInfo(ctx *context.Context) *common.CompareInfo {
402402
ci.HeadRepo = ctx.Repo.Repository
403403
ci.HeadGitRepo = ctx.Repo.GitRepo
404404
} else if has {
405-
ci.HeadGitRepo, err = gitrepo.OpenRepository(ctx, ci.HeadRepo)
405+
ci.HeadGitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ci.HeadRepo)
406406
if err != nil {
407-
ctx.ServerError("OpenRepository", err)
407+
ctx.ServerError("RepositoryFromRequestContextOrOpen", err)
408408
return nil
409409
}
410-
defer ci.HeadGitRepo.Close()
411410
} else {
412411
ctx.NotFound(nil)
413412
return nil
@@ -726,11 +725,6 @@ func getBranchesAndTagsForRepo(ctx gocontext.Context, repo *repo_model.Repositor
726725
// CompareDiff show different from one commit to another commit
727726
func CompareDiff(ctx *context.Context) {
728727
ci := ParseCompareInfo(ctx)
729-
defer func() {
730-
if ci != nil && ci.HeadGitRepo != nil {
731-
ci.HeadGitRepo.Close()
732-
}
733-
}()
734728
if ctx.Written() {
735729
return
736730
}

routers/web/repo/editor.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"code.gitea.io/gitea/modules/markup"
2121
"code.gitea.io/gitea/modules/setting"
2222
"code.gitea.io/gitea/modules/templates"
23-
"code.gitea.io/gitea/modules/typesniffer"
2423
"code.gitea.io/gitea/modules/util"
2524
"code.gitea.io/gitea/modules/web"
2625
"code.gitea.io/gitea/routers/utils"
@@ -151,22 +150,22 @@ func editFile(ctx *context.Context, isNewFile bool) {
151150
return
152151
}
153152

154-
dataRc, err := blob.DataAsync()
153+
buf, dataRc, fInfo, err := getFileReader(ctx, ctx.Repo.Repository.ID, blob)
155154
if err != nil {
156-
ctx.NotFound(err)
155+
if git.IsErrNotExist(err) {
156+
ctx.NotFound(err)
157+
} else {
158+
ctx.ServerError("getFileReader", err)
159+
}
157160
return
158161
}
159162

160163
defer dataRc.Close()
161164

162165
ctx.Data["FileSize"] = blob.Size()
163166

164-
buf := make([]byte, 1024)
165-
n, _ := util.ReadAtMost(dataRc, buf)
166-
buf = buf[:n]
167-
168167
// Only some file types are editable online as text.
169-
if !typesniffer.DetectContentType(buf).IsRepresentableAsText() {
168+
if !fInfo.st.IsRepresentableAsText() || fInfo.isLFSFile {
170169
ctx.NotFound(nil)
171170
return
172171
}

0 commit comments

Comments
 (0)