Skip to content

Commit b6a11e6

Browse files
kousuactions-user
authored andcommitted
git-annex: views for annex files (#22)
This updates the repo index/file view endpoints so annex files match the way LFS files are rendered, making annexed files accessible via the web instead of being black boxes only accessible by git clone. This mostly just duplicates the existing LFS logic. It doesn't try to combine itself with the existing logic, to make merging with upstream easier. If upstream ever decides to accept, I would like to try to merge the redundant logic. The one bit that doesn't directly copy LFS is my choice to hide annex-symlinks. LFS files are always _pointer files_ and therefore always render with the "file" icon and no special label, but annex files come in two flavours: symlinks or pointer files. I've conflated both kinds to try to give a consistent experience. The tests in here ensure the correct download link (/media, from the last PR) renders in both the toolbar and, if a binary file (like most annexed files will be), in the main pane, but it also adds quite a bit of code to make sure text files that happen to be annexed are dug out and rendered inline like LFS files are.
1 parent 67dd0b7 commit b6a11e6

31 files changed

+246
-11
lines changed

modules/base/tool.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"unicode"
2020
"unicode/utf8"
2121

22+
"code.gitea.io/gitea/modules/annex"
2223
"code.gitea.io/gitea/modules/git"
2324
"code.gitea.io/gitea/modules/log"
2425
"code.gitea.io/gitea/modules/setting"
@@ -204,6 +205,12 @@ func IsLetter(ch rune) bool {
204205
func EntryIcon(entry *git.TreeEntry) string {
205206
switch {
206207
case entry.IsLink():
208+
isAnnexed, _ := annex.IsAnnexed(entry.Blob())
209+
if isAnnexed {
210+
// git-annex files are sometimes stored as symlinks;
211+
// short-circuit that so like LFS they are displayed as regular files
212+
return "file"
213+
}
207214
te, err := entry.FollowLink()
208215
if err != nil {
209216
log.Debug(err.Error())

options/locale/locale_cs-CZ.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ view_git_blame=Zobrazit Git Blame
10921092
video_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 video.
10931093
audio_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 audio.
10941094
stored_lfs=Uloženo pomocí Git LFS
1095+
stored_annex=Uloženo pomocí Git Annex
10951096
symbolic_link=Symbolický odkaz
10961097
commit_graph=Graf commitů
10971098
commit_graph.select=Vybrat větve
@@ -1111,6 +1112,7 @@ editor.upload_file=Nahrát soubor
11111112
editor.edit_file=Upravit soubor
11121113
editor.preview_changes=Náhled změn
11131114
editor.cannot_edit_lfs_files=LFS soubory nemohou být upravovány přes webové rozhraní.
1115+
editor.cannot_edit_annex_files=Annex soubory nemohou být upravovány přes webové rozhraní.
11141116
editor.cannot_edit_non_text_files=Binární soubory nemohou být upravovány přes webové rozhraní.
11151117
editor.edit_this_file=Upravit soubor
11161118
editor.this_file_locked=Soubor je uzamčen

options/locale/locale_de-DE.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ view_git_blame=Git Blame ansehen
11201120
video_not_supported_in_browser=Dein Browser unterstützt das HTML5 'video'-Tag nicht.
11211121
audio_not_supported_in_browser=Dein Browser unterstützt den HTML5 'audio'-Tag nicht.
11221122
stored_lfs=Gespeichert mit Git LFS
1123+
stored_annex=Gespeichert mit Git Annex
11231124
symbolic_link=Softlink
11241125
commit_graph=Commit graph
11251126
commit_graph.select=Branches auswählen
@@ -1139,6 +1140,7 @@ editor.upload_file=Datei hochladen
11391140
editor.edit_file=Datei bearbeiten
11401141
editor.preview_changes=Vorschau der Änderungen
11411142
editor.cannot_edit_lfs_files=LFS-Dateien können im Webinterface nicht bearbeitet werden.
1143+
editor.cannot_edit_annex_files=Annex-Dateien können im Webinterface nicht bearbeitet werden.
11421144
editor.cannot_edit_non_text_files=Binärdateien können nicht im Webinterface bearbeitet werden.
11431145
editor.edit_this_file=Datei bearbeiten
11441146
editor.this_file_locked=Datei ist gesperrt

options/locale/locale_el-GR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ view_git_blame=Προβολή Git Blame
11081108
video_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'video'.
11091109
audio_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'audio'.
11101110
stored_lfs=Αποθηκεύτηκε με το Git LFS
1111+
stored_annex=Αποθηκεύτηκε με το Git Annex
11111112
symbolic_link=Symbolic link
11121113
commit_graph=Γράφημα Υποβολών
11131114
commit_graph.select=Επιλογή κλάδων
@@ -1127,6 +1128,7 @@ editor.upload_file=Ανέβασμα Αρχείου
11271128
editor.edit_file=Επεξεργασία Αρχείου
11281129
editor.preview_changes=Προεπισκόπηση Αλλαγών
11291130
editor.cannot_edit_lfs_files=Τα αρχεία LFS δεν μπορούν να επεξεργαστούν στη διεπαφή web.
1131+
editor.cannot_edit_annex_files=Τα αρχεία Annex δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11301132
editor.cannot_edit_non_text_files=Τα δυαδικά αρχεία δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11311133
editor.edit_this_file=Επεξεργασία Αρχείου
11321134
editor.this_file_locked=Το αρχείο είναι κλειδωμένο

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ view_git_blame = View Git Blame
11771177
video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag.
11781178
audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag.
11791179
stored_lfs = Stored with Git LFS
1180+
stored_annex = Stored with Git Annex
11801181
symbolic_link = Symbolic link
11811182
executable_file = Executable File
11821183
commit_graph = Commit Graph
@@ -1200,6 +1201,7 @@ editor.upload_file = Upload File
12001201
editor.edit_file = Edit File
12011202
editor.preview_changes = Preview Changes
12021203
editor.cannot_edit_lfs_files = LFS files cannot be edited in the web interface.
1204+
editor.cannot_edit_annex_files = Annex files cannot be edited in the web interface.
12031205
editor.cannot_edit_non_text_files = Binary files cannot be edited in the web interface.
12041206
editor.edit_this_file = Edit File
12051207
editor.this_file_locked = File is locked

options/locale/locale_es-ES.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,7 @@ view_git_blame=Ver la culpa de Git
10051005
video_not_supported_in_browser=Su navegador no soporta el tag video de HTML5.
10061006
audio_not_supported_in_browser=Su navegador no soporta el tag audio de HTML5.
10071007
stored_lfs=Almacenados con Git LFS
1008+
stored_annex=Almacenados con Git Annex
10081009
symbolic_link=Enlace simbólico
10091010
commit_graph=Gráfico de commits
10101011
commit_graph.select=Seleccionar ramas
@@ -1023,6 +1024,7 @@ editor.upload_file=Subir archivo
10231024
editor.edit_file=Editar Archivo
10241025
editor.preview_changes=Vista previa de los cambios
10251026
editor.cannot_edit_lfs_files=Los archivos LFS no se pueden editar en la interfaz web.
1027+
editor.cannot_edit_annex_files=Los archivos Annex no se pueden editar en la interfaz web.
10261028
editor.cannot_edit_non_text_files=Los archivos binarios no se pueden editar en la interfaz web.
10271029
editor.edit_this_file=Editar Archivo
10281030
editor.this_file_locked=El archivo está bloqueado

options/locale/locale_fa-IR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ file_copy_permalink=پرمالینک را کپی کنید
921921
video_not_supported_in_browser=مرورگر شما از تگ video که در HTML5 تعریف شده است، پشتیبانی نمی کند.
922922
audio_not_supported_in_browser=مرورگر شما از تگ audio که در HTML5 تعریف شده است، پشتیبانی نمی کند.
923923
stored_lfs=ذخیره شده با GIT LFS
924+
stored_annex=ذخیره شده با GIT Annex
924925
symbolic_link=پیوند نمادین
925926
commit_graph=نمودار کامیت
926927
commit_graph.select=انتخاب برنچها
@@ -938,6 +939,7 @@ editor.upload_file=بارگذاری پرونده
938939
editor.edit_file=ویرایش پرونده
939940
editor.preview_changes=پیش نمایش تغییرات
940941
editor.cannot_edit_lfs_files=پرونده های LFS در صحفه وب قابل تغییر نیست.
942+
editor.cannot_edit_annex_files=پرونده های Annex در صحفه وب قابل تغییر نیست.
941943
editor.cannot_edit_non_text_files=پرونده‎های دودویی در صفحه وب قابل تغییر نیست.
942944
editor.edit_this_file=ویرایش پرونده
943945
editor.this_file_locked=پرونده قفل شده است

options/locale/locale_fr-FR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ view_git_blame=Voir Git Blâme
11671167
video_not_supported_in_browser=Votre navigateur ne supporte pas la balise « vidéo » HTML5.
11681168
audio_not_supported_in_browser=Votre navigateur ne supporte pas la balise « audio » HTML5.
11691169
stored_lfs=Stocké avec Git LFS
1170+
stored_annex=Stocké avec Git Annex
11701171
symbolic_link=Lien symbolique
11711172
executable_file=Fichiers exécutables
11721173
commit_graph=Graphe des révisions
@@ -1190,6 +1191,7 @@ editor.upload_file=Téléverser un fichier
11901191
editor.edit_file=Modifier le fichier
11911192
editor.preview_changes=Aperçu des modifications
11921193
editor.cannot_edit_lfs_files=Les fichiers LFS ne peuvent pas être modifiés dans l'interface web.
1194+
editor.cannot_edit_annex_files=Les fichiers Annex ne peuvent pas être modifiés dans l'interface web.
11931195
editor.cannot_edit_non_text_files=Les fichiers binaires ne peuvent pas être édités dans l'interface web.
11941196
editor.edit_this_file=Modifier le fichier
11951197
editor.this_file_locked=Le fichier est verrouillé

options/locale/locale_hu-HU.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ file_too_large=Ez a fájl túl nagy ahhoz, hogy megjelenítsük.
690690
video_not_supported_in_browser=A böngésző nem támogatja a HTML5 video tag-et.
691691
audio_not_supported_in_browser=A böngésző nem támogatja a HTML5 audio tag-et.
692692
stored_lfs=Git LFS-el eltárolva
693+
stored_annex=Git Annex-el eltárolva
693694
symbolic_link=Szimbolikus hivatkozás
694695
commit_graph=Commit gráf
695696
commit_graph.hide_pr_refs=Pull request-ek elrejtése
@@ -702,6 +703,7 @@ editor.upload_file=Fájl feltöltése
702703
editor.edit_file=Fájl szerkesztése
703704
editor.preview_changes=Változások előnézete
704705
editor.cannot_edit_lfs_files=LFS fájlok nem szerkeszthetőek a webes felületen.
706+
editor.cannot_edit_annex_files=Annex fájlok nem szerkeszthetőek a webes felületen.
705707
editor.cannot_edit_non_text_files=Bináris fájlok nem szerkeszthetőek a webes felületen.
706708
editor.edit_this_file=Fájl szerkesztése
707709
editor.this_file_locked=Zárolt állomány

options/locale/locale_id-ID.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ file_permalink=Permalink
596596
file_too_large=Berkas terlalu besar untuk ditampilkan.
597597

598598
stored_lfs=Tersimpan dengan GIT LFS
599+
stored_annex=Tersimpan dengan GIT Annex
599600
commit_graph=Grafik Komit
600601
blame=Salahkan
601602
normal_view=Pandangan Normal
@@ -607,6 +608,7 @@ editor.upload_file=Unggah Berkas
607608
editor.edit_file=Sunting Berkas
608609
editor.preview_changes=Tinjau Perubahan
609610
editor.cannot_edit_lfs_files=Berkas LFS tidak dapat disunting dalam antarmuka web.
611+
editor.cannot_edit_annex_files=Berkas Annex tidak dapat disunting dalam antarmuka web.
610612
editor.cannot_edit_non_text_files=Berkas biner tidak dapat disunting dalam antarmuka web.
611613
editor.edit_this_file=Sunting Berkas
612614
editor.this_file_locked=Berkas terkunci

0 commit comments

Comments
 (0)