From c03e488e14fdaf1c0056952f40c5fc8124719a30 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 9 Apr 2021 00:25:57 +0200 Subject: Add LFS Migration and Mirror (#14726) * Implemented LFS client. * Implemented scanning for pointer files. * Implemented downloading of lfs files. * Moved model-dependent code into services. * Removed models dependency. Added TryReadPointerFromBuffer. * Migrated code from service to module. * Centralised storage creation. * Removed dependency from models. * Moved ContentStore into modules. * Share structs between server and client. * Moved method to services. * Implemented lfs download on clone. * Implemented LFS sync on clone and mirror update. * Added form fields. * Updated templates. * Fixed condition. * Use alternate endpoint. * Added missing methods. * Fixed typo and make linter happy. * Detached pointer parser from gogit dependency. * Fixed TestGetLFSRange test. * Added context to support cancellation. * Use ReadFull to probably read more data. * Removed duplicated code from models. * Moved scan implementation into pointer_scanner_nogogit. * Changed method name. * Added comments. * Added more/specific log/error messages. * Embedded lfs.Pointer into models.LFSMetaObject. * Moved code from models to module. * Moved code from models to module. * Moved code from models to module. * Reduced pointer usage. * Embedded type. * Use promoted fields. * Fixed unexpected eof. * Added unit tests. * Implemented migration of local file paths. * Show an error on invalid LFS endpoints. * Hide settings if not used. * Added LFS info to mirror struct. * Fixed comment. * Check LFS endpoint. * Manage LFS settings from mirror page. * Fixed selector. * Adjusted selector. * Added more tests. * Added local filesystem migration test. * Fixed typo. * Reset settings. * Added special windows path handling. * Added unit test for HTTPClient. * Added unit test for BasicTransferAdapter. * Moved into util package. * Test if LFS endpoint is allowed. * Added support for git:// * Just use a static placeholder as the displayed url may be invalid. * Reverted to original code. * Added "Advanced Settings". * Updated wording. * Added discovery info link. * Implemented suggestion. * Fixed missing format parameter. * Added Pointer.IsValid(). * Always remove model on error. * Added suggestions. * Use channel instead of array. * Update routers/repo/migrate.go * fmt Signed-off-by: Andrew Thornton Co-authored-by: zeripath --- templates/repo/migrate/git.tmpl | 14 +------------- templates/repo/migrate/gitea.tmpl | 16 ++-------------- templates/repo/migrate/github.tmpl | 16 ++-------------- templates/repo/migrate/gitlab.tmpl | 16 ++-------------- templates/repo/migrate/gogs.tmpl | 16 ++-------------- templates/repo/migrate/options.tmpl | 29 +++++++++++++++++++++++++++++ templates/repo/settings/options.tmpl | 19 +++++++++++++++++-- 7 files changed, 55 insertions(+), 71 deletions(-) create mode 100644 templates/repo/migrate/options.tmpl (limited to 'templates/repo') diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index 233a019435..6525a9b4f5 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -15,7 +15,6 @@ {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} - {{if .LFSActive}}
{{.i18n.Tr "repo.migrate.lfs_mirror_unsupported"}}{{end}}
@@ -28,18 +27,7 @@
-
- -
- {{if .DisableMirrors}} - - - {{else}} - - - {{end}} -
-
+ {{template "repo/migrate/options" .}}
diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl index b21e6b18ff..52528fc57c 100644 --- a/templates/repo/migrate/gitea.tmpl +++ b/templates/repo/migrate/gitea.tmpl @@ -15,28 +15,16 @@ {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} - {{if .LFSActive}}
{{.i18n.Tr "repo.migrate.lfs_mirror_unsupported"}}{{end}}
- {{svg "octicon-question"}} + {{svg "octicon-question"}}
-
- -
- {{if .DisableMirrors}} - - - {{else}} - - - {{end}} -
-
+ {{template "repo/migrate/options" .}} {{.i18n.Tr "repo.migrate.migrate_items_options"}}
diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl index 06f76d7298..b7c5bd5b0d 100644 --- a/templates/repo/migrate/github.tmpl +++ b/templates/repo/migrate/github.tmpl @@ -15,28 +15,16 @@ {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} - {{if .LFSActive}}
{{.i18n.Tr "repo.migrate.lfs_mirror_unsupported"}}{{end}}
- {{svg "octicon-question"}} + {{svg "octicon-question"}}
-
- -
- {{if .DisableMirrors}} - - - {{else}} - - - {{end}} -
-
+ {{template "repo/migrate/options" .}} {{.i18n.Tr "repo.migrate.migrate_items_options"}}
diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl index 545a1ff437..26eebd18bb 100644 --- a/templates/repo/migrate/gitlab.tmpl +++ b/templates/repo/migrate/gitlab.tmpl @@ -15,28 +15,16 @@ {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} - {{if .LFSActive}}
{{.i18n.Tr "repo.migrate.lfs_mirror_unsupported"}}{{end}}
- {{svg "octicon-question"}} + {{svg "octicon-question"}}
-
- -
- {{if .DisableMirrors}} - - - {{else}} - - - {{end}} -
-
+ {{template "repo/migrate/options" .}} {{.i18n.Tr "repo.migrate.migrate_items_options"}}
diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl index ac81872b92..dc83ac5bb8 100644 --- a/templates/repo/migrate/gogs.tmpl +++ b/templates/repo/migrate/gogs.tmpl @@ -15,28 +15,16 @@ {{.i18n.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.i18n.Tr "repo.migrate.clone_local_path"}}{{end}} - {{if .LFSActive}}
{{.i18n.Tr "repo.migrate.lfs_mirror_unsupported"}}{{end}}
- +
-
- -
- {{if .DisableMirrors}} - - - {{else}} - - - {{end}} -
-
+ {{template "repo/migrate/options" .}} {{.i18n.Tr "repo.migrate.migrate_items_options"}}
diff --git a/templates/repo/migrate/options.tmpl b/templates/repo/migrate/options.tmpl new file mode 100644 index 0000000000..bca773a53f --- /dev/null +++ b/templates/repo/migrate/options.tmpl @@ -0,0 +1,29 @@ +
+ +
+ {{if .DisableMirrors}} + + + {{else}} + + + {{end}} +
+
+{{if .LFSActive}} +
+ +
+ + +
+ +
+ +{{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 514a2f5c0a..012bff317d 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -81,8 +81,8 @@
- - + +
@@ -112,6 +112,21 @@
+ {{if .LFSStartServer}} +
+ +
+ + +
+
+
+ + +

{{.i18n.Tr "repo.mirror_lfs_endpoint_desc" "https://github.com/git-lfs/git-lfs/blob/main/docs/api/server-discovery.md#server-discovery" | Str2html}}

+
+ {{end}} +
-- cgit v1.2.3