Skip to content

Commit a35f475

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 012c6c8 commit a35f475

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
@@ -1094,6 +1094,7 @@ view_git_blame=Zobrazit Git Blame
10941094
video_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 video.
10951095
audio_not_supported_in_browser=Váš prohlížeč nepodporuje značku pro HTML5 audio.
10961096
stored_lfs=Uloženo pomocí Git LFS
1097+
stored_annex=Uloženo pomocí Git Annex
10971098
symbolic_link=Symbolický odkaz
10981099
commit_graph=Graf commitů
10991100
commit_graph.select=Vybrat větve
@@ -1113,6 +1114,7 @@ editor.upload_file=Nahrát soubor
11131114
editor.edit_file=Upravit soubor
11141115
editor.preview_changes=Náhled změn
11151116
editor.cannot_edit_lfs_files=LFS soubory nemohou být upravovány přes webové rozhraní.
1117+
editor.cannot_edit_annex_files=Annex soubory nemohou být upravovány přes webové rozhraní.
11161118
editor.cannot_edit_non_text_files=Binární soubory nemohou být upravovány přes webové rozhraní.
11171119
editor.edit_this_file=Upravit soubor
11181120
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
@@ -1182,6 +1182,7 @@ view_git_blame=Git Blame ansehen
11821182
video_not_supported_in_browser=Dein Browser unterstützt das HTML5 'video'-Tag nicht.
11831183
audio_not_supported_in_browser=Dein Browser unterstützt den HTML5 'audio'-Tag nicht.
11841184
stored_lfs=Gespeichert mit Git LFS
1185+
stored_annex=Gespeichert mit Git Annex
11851186
symbolic_link=Softlink
11861187
executable_file=Ausführbare Datei
11871188
commit_graph=Commit graph
@@ -1205,6 +1206,7 @@ editor.upload_file=Datei hochladen
12051206
editor.edit_file=Datei bearbeiten
12061207
editor.preview_changes=Vorschau der Änderungen
12071208
editor.cannot_edit_lfs_files=LFS-Dateien können im Webinterface nicht bearbeitet werden.
1209+
editor.cannot_edit_annex_files=Annex-Dateien können im Webinterface nicht bearbeitet werden.
12081210
editor.cannot_edit_non_text_files=Binärdateien können nicht im Webinterface bearbeitet werden.
12091211
editor.edit_this_file=Datei bearbeiten
12101212
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
@@ -1111,6 +1111,7 @@ view_git_blame=Προβολή Git Blame
11111111
video_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'video'.
11121112
audio_not_supported_in_browser=Το πρόγραμμα περιήγησής σας δεν υποστηρίζει την ετικέτα HTML5 'audio'.
11131113
stored_lfs=Αποθηκεύτηκε με το Git LFS
1114+
stored_annex=Αποθηκεύτηκε με το Git Annex
11141115
symbolic_link=Symbolic link
11151116
commit_graph=Γράφημα Υποβολών
11161117
commit_graph.select=Επιλογή κλάδων
@@ -1130,6 +1131,7 @@ editor.upload_file=Ανέβασμα Αρχείου
11301131
editor.edit_file=Επεξεργασία Αρχείου
11311132
editor.preview_changes=Προεπισκόπηση Αλλαγών
11321133
editor.cannot_edit_lfs_files=Τα αρχεία LFS δεν μπορούν να επεξεργαστούν στη διεπαφή web.
1134+
editor.cannot_edit_annex_files=Τα αρχεία Annex δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11331135
editor.cannot_edit_non_text_files=Τα δυαδικά αρχεία δεν μπορούν να επεξεργαστούν στη διεπαφή web.
11341136
editor.edit_this_file=Επεξεργασία Αρχείου
11351137
editor.this_file_locked=Το αρχείο είναι κλειδωμένο

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ view_git_blame = View Git Blame
11791179
video_not_supported_in_browser = Your browser does not support the HTML5 'video' tag.
11801180
audio_not_supported_in_browser = Your browser does not support the HTML5 'audio' tag.
11811181
stored_lfs = Stored with Git LFS
1182+
stored_annex = Stored with Git Annex
11821183
symbolic_link = Symbolic link
11831184
executable_file = Executable File
11841185
commit_graph = Commit Graph
@@ -1202,6 +1203,7 @@ editor.upload_file = Upload File
12021203
editor.edit_file = Edit File
12031204
editor.preview_changes = Preview Changes
12041205
editor.cannot_edit_lfs_files = LFS files cannot be edited in the web interface.
1206+
editor.cannot_edit_annex_files = Annex files cannot be edited in the web interface.
12051207
editor.cannot_edit_non_text_files = Binary files cannot be edited in the web interface.
12061208
editor.edit_this_file = Edit File
12071209
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
@@ -1182,6 +1182,7 @@ view_git_blame=Ver la culpa de Git
11821182
video_not_supported_in_browser=Su navegador no soporta el tag video de HTML5.
11831183
audio_not_supported_in_browser=Su navegador no soporta el tag audio de HTML5.
11841184
stored_lfs=Almacenados con Git LFS
1185+
stored_annex=Almacenados con Git Annex
11851186
symbolic_link=Enlace simbólico
11861187
executable_file=Archivo Ejecutable
11871188
commit_graph=Gráfico de commits
@@ -1205,6 +1206,7 @@ editor.upload_file=Subir archivo
12051206
editor.edit_file=Editar Archivo
12061207
editor.preview_changes=Vista previa de los cambios
12071208
editor.cannot_edit_lfs_files=Los archivos LFS no se pueden editar en la interfaz web.
1209+
editor.cannot_edit_annex_files=Los archivos Annex no se pueden editar en la interfaz web.
12081210
editor.cannot_edit_non_text_files=Los archivos binarios no se pueden editar en la interfaz web.
12091211
editor.edit_this_file=Editar Archivo
12101212
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
@@ -923,6 +923,7 @@ file_copy_permalink=پرمالینک را کپی کنید
923923
video_not_supported_in_browser=مرورگر شما از تگ video که در HTML5 تعریف شده است، پشتیبانی نمی کند.
924924
audio_not_supported_in_browser=مرورگر شما از تگ audio که در HTML5 تعریف شده است، پشتیبانی نمی کند.
925925
stored_lfs=ذخیره شده با GIT LFS
926+
stored_annex=ذخیره شده با GIT Annex
926927
symbolic_link=پیوند نمادین
927928
commit_graph=نمودار کامیت
928929
commit_graph.select=انتخاب برنچها
@@ -940,6 +941,7 @@ editor.upload_file=بارگذاری پرونده
940941
editor.edit_file=ویرایش پرونده
941942
editor.preview_changes=پیش نمایش تغییرات
942943
editor.cannot_edit_lfs_files=پرونده های LFS در صحفه وب قابل تغییر نیست.
944+
editor.cannot_edit_annex_files=پرونده های Annex در صحفه وب قابل تغییر نیست.
943945
editor.cannot_edit_non_text_files=پرونده‎های دودویی در صفحه وب قابل تغییر نیست.
944946
editor.edit_this_file=ویرایش پرونده
945947
editor.this_file_locked=پرونده قفل شده است

options/locale/locale_fr-FR.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ view_git_blame=Voir Git Blâme
11821182
video_not_supported_in_browser=Votre navigateur ne supporte pas la balise « vidéo » HTML5.
11831183
audio_not_supported_in_browser=Votre navigateur ne supporte pas la balise « audio » HTML5.
11841184
stored_lfs=Stocké avec Git LFS
1185+
stored_annex=Stocké avec Git Annex
11851186
symbolic_link=Lien symbolique
11861187
executable_file=Fichiers exécutables
11871188
commit_graph=Graphe des révisions
@@ -1205,6 +1206,7 @@ editor.upload_file=Téléverser un fichier
12051206
editor.edit_file=Modifier le fichier
12061207
editor.preview_changes=Aperçu des modifications
12071208
editor.cannot_edit_lfs_files=Les fichiers LFS ne peuvent pas être modifiés dans l'interface web.
1209+
editor.cannot_edit_annex_files=Les fichiers Annex ne peuvent pas être modifiés dans l'interface web.
12081210
editor.cannot_edit_non_text_files=Les fichiers binaires ne peuvent pas être édités dans l'interface web.
12091211
editor.edit_this_file=Modifier le fichier
12101212
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
@@ -692,6 +692,7 @@ file_too_large=Ez a fájl túl nagy ahhoz, hogy megjelenítsük.
692692
video_not_supported_in_browser=A böngésző nem támogatja a HTML5 video tag-et.
693693
audio_not_supported_in_browser=A böngésző nem támogatja a HTML5 audio tag-et.
694694
stored_lfs=Git LFS-el eltárolva
695+
stored_annex=Git Annex-el eltárolva
695696
symbolic_link=Szimbolikus hivatkozás
696697
commit_graph=Commit gráf
697698
commit_graph.hide_pr_refs=Pull request-ek elrejtése
@@ -704,6 +705,7 @@ editor.upload_file=Fájl feltöltése
704705
editor.edit_file=Fájl szerkesztése
705706
editor.preview_changes=Változások előnézete
706707
editor.cannot_edit_lfs_files=LFS fájlok nem szerkeszthetőek a webes felületen.
708+
editor.cannot_edit_annex_files=Annex fájlok nem szerkeszthetőek a webes felületen.
707709
editor.cannot_edit_non_text_files=Bináris fájlok nem szerkeszthetőek a webes felületen.
708710
editor.edit_this_file=Fájl szerkesztése
709711
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
@@ -598,6 +598,7 @@ file_permalink=Permalink
598598
file_too_large=Berkas terlalu besar untuk ditampilkan.
599599

600600
stored_lfs=Tersimpan dengan GIT LFS
601+
stored_annex=Tersimpan dengan GIT Annex
601602
commit_graph=Grafik Komit
602603
blame=Salahkan
603604
normal_view=Pandangan Normal
@@ -609,6 +610,7 @@ editor.upload_file=Unggah Berkas
609610
editor.edit_file=Sunting Berkas
610611
editor.preview_changes=Tinjau Perubahan
611612
editor.cannot_edit_lfs_files=Berkas LFS tidak dapat disunting dalam antarmuka web.
613+
editor.cannot_edit_annex_files=Berkas Annex tidak dapat disunting dalam antarmuka web.
612614
editor.cannot_edit_non_text_files=Berkas biner tidak dapat disunting dalam antarmuka web.
613615
editor.edit_this_file=Sunting Berkas
614616
editor.this_file_locked=Berkas terkunci

0 commit comments

Comments
 (0)