Skip to content

Commit 24daa8f

Browse files
committed
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 622a8cb commit 24daa8f

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
@@ -998,6 +998,7 @@ view_git_blame=Zobrazit Git Blame
998998
video_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 video.
999999
audio_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 audio.
10001000
stored_lfs=Uloženo pomocí Git LFS
1001+
stored_annex=Uloženo pomocí Git Annex
10011002
symbolic_link=Symbolický odkaz
10021003
commit_graph=Graf commitů
10031004
commit_graph.select=Vybrat větve
@@ -1015,6 +1016,7 @@ editor.upload_file=Nahrát soubor
10151016
editor.edit_file=Upravit soubor
10161017
editor.preview_changes=Náhled změn
10171018
editor.cannot_edit_lfs_files=LFS soubory nemohou být upravovány přes webové rozhraní.
1019+
editor.cannot_edit_annex_files=Annex soubory nemohou být upravovány přes webové rozhraní.
10181020
editor.cannot_edit_non_text_files=Binární soubory nemohou být upravovány přes webové rozhraní.
10191021
editor.edit_this_file=Upravit soubor
10201022
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
@@ -1067,6 +1067,7 @@ view_git_blame=Git Blame ansehen
10671067
video_not_supported_in_browser=Dein Browser unterstützt das HTML5 'video'-Tag nicht.
10681068
audio_not_supported_in_browser=Dein Browser unterstützt den HTML5 'audio'-Tag nicht.
10691069
stored_lfs=Gespeichert mit Git LFS
1070+
stored_annex=Gespeichert mit Git Annex
10701071
symbolic_link=Softlink
10711072
commit_graph=Commit graph
10721073
commit_graph.select=Branches auswählen
@@ -1084,6 +1085,7 @@ editor.upload_file=Datei hochladen
10841085
editor.edit_file=Datei bearbeiten
10851086
editor.preview_changes=Vorschau der Änderungen
10861087
editor.cannot_edit_lfs_files=LFS-Dateien können im Webinterface nicht bearbeitet werden.
1088+
editor.cannot_edit_annex_files=Annex-Dateien können im Webinterface nicht bearbeitet werden.
10871089
editor.cannot_edit_non_text_files=Binärdateien können nicht im Webinterface bearbeitet werden.
10881090
editor.edit_this_file=Datei bearbeiten
10891091
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
@@ -1085,6 +1085,7 @@ view_git_blame=Προβολή Git Blame
10851085
video_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'video'.
10861086
audio_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'audio'.
10871087
stored_lfs=Αποθηκεύτηκε με το Git LFS
1088+
stored_annex=Αποθηκεύτηκε με το Git Annex
10881089
symbolic_link=Symbolic link
10891090
commit_graph=Γράφημα Υποβολών
10901091
commit_graph.select=Επιλογή κλάδων
@@ -1103,6 +1104,7 @@ editor.upload_file=Ανέβασμα Αρχείου
11031104
editor.edit_file=Επεξεργασία Αρχείου
11041105
editor.preview_changes=Προεπισκόπηση Αλλαγών
11051106
editor.cannot_edit_lfs_files=Τα αρχεία LFS δεν μπορούν να επεξεργαστούν στη διεπαφή web.
1107+
editor.cannot_edit_annex_files=Τα αρχεία Annex δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11061108
editor.cannot_edit_non_text_files=Τα δυαδικά αρχεία δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11071109
editor.edit_this_file=Επεξεργασία Αρχείου
11081110
editor.this_file_locked=Το αρχείο είναι κλειδωμένο

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ view_git_blame = View Git Blame
11561156
video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag.
11571157
audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag.
11581158
stored_lfs = Stored with Git LFS
1159+
stored_annex = Stored with Git Annex
11591160
symbolic_link = Symbolic link
11601161
executable_file = Executable File
11611162
commit_graph = Commit Graph
@@ -1176,6 +1177,7 @@ editor.upload_file = Upload File
11761177
editor.edit_file = Edit File
11771178
editor.preview_changes = Preview Changes
11781179
editor.cannot_edit_lfs_files = LFS files cannot be edited in the web interface.
1180+
editor.cannot_edit_annex_files = Annex files cannot be edited in the web interface.
11791181
editor.cannot_edit_non_text_files = Binary files cannot be edited in the web interface.
11801182
editor.edit_this_file = Edit File
11811183
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
@@ -981,6 +981,7 @@ view_git_blame=Ver la culpa de Git
981981
video_not_supported_in_browser=Su navegador no soporta el tag video de HTML5.
982982
audio_not_supported_in_browser=Su navegador no soporta el tag audio de HTML5.
983983
stored_lfs=Almacenados con Git LFS
984+
stored_annex=Almacenados con Git Annex
984985
symbolic_link=Enlace simbólico
985986
commit_graph=Gráfico de commits
986987
commit_graph.select=Seleccionar ramas
@@ -998,6 +999,7 @@ editor.upload_file=Subir archivo
998999
editor.edit_file=Editar Archivo
9991000
editor.preview_changes=Vista previa de los cambios
10001001
editor.cannot_edit_lfs_files=Los archivos LFS no se pueden editar en la interfaz web.
1002+
editor.cannot_edit_annex_files=Los archivos Annex no se pueden editar en la interfaz web.
10011003
editor.cannot_edit_non_text_files=Los archivos binarios no se pueden editar en la interfaz web.
10021004
editor.edit_this_file=Editar Archivo
10031005
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
@@ -894,6 +894,7 @@ file_copy_permalink=پرمالینک را کپی کنید
894894
video_not_supported_in_browser=مرورگر شما از تگ video که در HTML5 تعریف شده است، پشتیبانی نمی کند.
895895
audio_not_supported_in_browser=مرورگر شما از تگ audio که در HTML5 تعریف شده است، پشتیبانی نمی کند.
896896
stored_lfs=ذخیره شده با GIT LFS
897+
stored_annex=ذخیره شده با GIT Annex
897898
symbolic_link=پیوند نمادین
898899
commit_graph=نمودار کامیت
899900
commit_graph.select=انتخاب برنچها
@@ -910,6 +911,7 @@ editor.upload_file=بارگذاری پرونده
910911
editor.edit_file=ویرایش پرونده
911912
editor.preview_changes=پیش نمایش تغییرات
912913
editor.cannot_edit_lfs_files=پرونده های LFS در صحفه وب قابل تغییر نیست.
914+
editor.cannot_edit_annex_files=پرونده های Annex در صحفه وب قابل تغییر نیست.
913915
editor.cannot_edit_non_text_files=پرونده‎های دودویی در صفحه وب قابل تغییر نیست.
914916
editor.edit_this_file=ویرایش پرونده
915917
editor.this_file_locked=پرونده قفل شده است

options/locale/locale_fr-FR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ view_git_blame=Voir Git Blâme
10771077
video_not_supported_in_browser=Votre navigateur ne supporte pas le tag HTML5 "video".
10781078
audio_not_supported_in_browser=Votre navigateur ne supporte pas la balise « audio » HTML5.
10791079
stored_lfs=Stocké avec Git LFS
1080+
stored_annex=Stocké avec Git Annex
10801081
symbolic_link=Lien symbolique
10811082
commit_graph=Graphique des révisions
10821083
commit_graph.select=Sélectionner les branches
@@ -1095,6 +1096,7 @@ editor.upload_file=Téléverser un fichier
10951096
editor.edit_file=Modifier le fichier
10961097
editor.preview_changes=Aperçu des modifications
10971098
editor.cannot_edit_lfs_files=Les fichiers LFS ne peuvent pas être modifiés dans l'interface web.
1099+
editor.cannot_edit_annex_files=Les fichiers Annex ne peuvent pas être modifiés dans l'interface web.
10981100
editor.cannot_edit_non_text_files=Les fichiers binaires ne peuvent pas être édités dans l'interface web.
10991101
editor.edit_this_file=Modifier le fichier
11001102
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
@@ -646,6 +646,7 @@ file_too_large=Ez a fájl túl nagy ahhoz, hogy megjelenítsük.
646646
video_not_supported_in_browser=A böngésző nem támogatja a HTML5 video tag-et.
647647
audio_not_supported_in_browser=A böngésző nem támogatja a HTML5 audio tag-et.
648648
stored_lfs=Git LFS-el eltárolva
649+
stored_annex=Git Annex-el eltárolva
649650
symbolic_link=Szimbolikus hivatkozás
650651
commit_graph=Commit gráf
651652
commit_graph.hide_pr_refs=Pull request-ek elrejtése
@@ -657,6 +658,7 @@ editor.upload_file=Fájl feltöltése
657658
editor.edit_file=Fájl szerkesztése
658659
editor.preview_changes=Változások előnézete
659660
editor.cannot_edit_lfs_files=LFS fájlok nem szerkeszthetőek a webes felületen.
661+
editor.cannot_edit_annex_files=Annex fájlok nem szerkeszthetőek a webes felületen.
660662
editor.cannot_edit_non_text_files=Bináris fájlok nem szerkeszthetőek a webes felületen.
661663
editor.edit_this_file=Fájl szerkesztése
662664
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
@@ -554,6 +554,7 @@ file_view_raw=Lihat Mentah
554554
file_permalink=Permalink
555555
file_too_large=Berkas terlalu besar untuk ditampilkan.
556556
stored_lfs=Tersimpan dengan GIT LFS
557+
stored_annex=Tersimpan dengan GIT Annex
557558
commit_graph=Grafik Komit
558559
blame=Salahkan
559560
normal_view=Pandangan Normal
@@ -564,6 +565,7 @@ editor.upload_file=Unggah Berkas
564565
editor.edit_file=Sunting Berkas
565566
editor.preview_changes=Tinjau Perubahan
566567
editor.cannot_edit_lfs_files=Berkas LFS tidak dapat disunting dalam antarmuka web.
568+
editor.cannot_edit_annex_files=Berkas Annex tidak dapat disunting dalam antarmuka web.
567569
editor.cannot_edit_non_text_files=Berkas biner tidak dapat disunting dalam antarmuka web.
568570
editor.edit_this_file=Sunting Berkas
569571
editor.this_file_locked=Berkas terkunci

0 commit comments

Comments
 (0)