From a878adfe628cf6dc367a17c3715fcd3499aa02b6 Mon Sep 17 00:00:00 2001 From: cassiozareck Date: Mon, 14 Aug 2023 16:52:44 -0300 Subject: [PATCH 1/3] Adding Forgero Git Service Signed-off-by: cassiozareck --- modules/structs/repo.go | 6 +- templates/repo/migrate/forgejo.tmpl | 130 ++++++++++++++++++++++++++++ web_src/svg/gitea-forgejo.svg | 1 + 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 templates/repo/migrate/forgejo.tmpl create mode 100644 web_src/svg/gitea-forgejo.svg diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 6a2ba4836b..80df8f2fc2 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -286,6 +286,7 @@ const ( OneDevService // 6 onedev service GitBucketService // 7 gitbucket service CodebaseService // 8 codebase service + ForgejoService // 9 forgejo service ) // Name represents the service type's name @@ -313,6 +314,8 @@ func (gt GitServiceType) Title() string { return "Codebase" case PlainGitService: return "Git" + case ForgejoService: + return "Forgejo" } return "" } @@ -352,7 +355,7 @@ type MigrateRepoOptions struct { // TokenAuth represents whether a service type supports token-based auth func (gt GitServiceType) TokenAuth() bool { switch gt { - case GithubService, GiteaService, GitlabService: + case GithubService, GiteaService, GitlabService, ForgejoService: return true } return false @@ -368,6 +371,7 @@ var SupportedFullGitService = []GitServiceType{ OneDevService, GitBucketService, CodebaseService, + ForgejoService, } // RepoTransfer represents a pending repo transfer diff --git a/templates/repo/migrate/forgejo.tmpl b/templates/repo/migrate/forgejo.tmpl new file mode 100644 index 0000000000..dd62e80479 --- /dev/null +++ b/templates/repo/migrate/forgejo.tmpl @@ -0,0 +1,130 @@ +{{template "base/head" .}} +
+
+
+
+ {{.CsrfTokenHtml}} +

+ {{.locale.Tr "repo.migrate.migrate" .service.Title}} + +

+
+ {{template "base/alert" .}} +
+ + + + {{.locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.locale.Tr "repo.migrate.clone_local_path"}}{{end}} + +
+ +
+ + + +
+ + {{template "repo/migrate/options" .}} + +
+ +
+ + +
+
+ +
+ {{.locale.Tr "repo.migrate.migrate_items_options"}} +
+ +
+ + +
+
+ + +
+
+
+ +
+ + +
+
+ +
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+ {{if .IsForcedPrivate}} + + + {{else}} + + + {{end}} +
+
+
+ + +
+ +
+ + +
+
+
+
+
+
+{{template "base/footer" .}} diff --git a/web_src/svg/gitea-forgejo.svg b/web_src/svg/gitea-forgejo.svg new file mode 100644 index 0000000000..8b8a7b5fed --- /dev/null +++ b/web_src/svg/gitea-forgejo.svg @@ -0,0 +1 @@ + \ No newline at end of file From 13738c03804d019f28550e46a4ebc37dbe3a5cfc Mon Sep 17 00:00:00 2001 From: cassiozareck Date: Tue, 15 Aug 2023 13:41:35 -0300 Subject: [PATCH 2/3] Adding description and Forgejo SVG --- modules/structs/repo.go | 18 +++++++++--------- options/locale/locale_en-US.ini | 1 + public/assets/img/svg/gitea-forgejo.svg | 9 +++++++++ web_src/svg/gitea-forgejo.svg | 10 +++++++++- 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 public/assets/img/svg/gitea-forgejo.svg diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 80df8f2fc2..461ad42ac7 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -281,12 +281,12 @@ const ( PlainGitService // 1 plain git service GithubService // 2 github.com GiteaService // 3 gitea service - GitlabService // 4 gitlab service - GogsService // 5 gogs service - OneDevService // 6 onedev service - GitBucketService // 7 gitbucket service - CodebaseService // 8 codebase service - ForgejoService // 9 forgejo service + ForgejoService // 4 forgejo service + GitlabService // 5 gitlab service + GogsService // 6 gogs service + OneDevService // 7 onedev service + GitBucketService // 8 gitbucket service + CodebaseService // 9 codebase service ) // Name represents the service type's name @@ -302,6 +302,8 @@ func (gt GitServiceType) Title() string { return "GitHub" case GiteaService: return "Gitea" + case ForgejoService: + return "Forgejo" case GitlabService: return "GitLab" case GogsService: @@ -314,8 +316,6 @@ func (gt GitServiceType) Title() string { return "Codebase" case PlainGitService: return "Git" - case ForgejoService: - return "Forgejo" } return "" } @@ -366,12 +366,12 @@ func (gt GitServiceType) TokenAuth() bool { var SupportedFullGitService = []GitServiceType{ GithubService, GitlabService, + ForgejoService, GiteaService, GogsService, OneDevService, GitBucketService, CodebaseService, - ForgejoService, } // RepoTransfer represents a pending repo transfer diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 30fa899c9d..a166af2477 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1080,6 +1080,7 @@ migrate.migrating_failed_no_addr = Migration failed. migrate.github.description = Migrate data from github.com or other GitHub instances. migrate.git.description = Migrate a repository only from any Git service. migrate.gitlab.description = Migrate data from gitlab.com or other GitLab instances. +migrate.forgejo.description = Migrate data from codeberg.org or other Forgejo instances. migrate.gitea.description = Migrate data from gitea.com or other Gitea instances. migrate.gogs.description = Migrate data from notabug.org or other Gogs instances. migrate.onedev.description = Migrate data from code.onedev.io or other OneDev instances. diff --git a/public/assets/img/svg/gitea-forgejo.svg b/public/assets/img/svg/gitea-forgejo.svg new file mode 100644 index 0000000000..ef617c00f3 --- /dev/null +++ b/public/assets/img/svg/gitea-forgejo.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/web_src/svg/gitea-forgejo.svg b/web_src/svg/gitea-forgejo.svg index 8b8a7b5fed..e00e5963cf 100644 --- a/web_src/svg/gitea-forgejo.svg +++ b/web_src/svg/gitea-forgejo.svg @@ -1 +1,9 @@ - \ No newline at end of file + From 9ae51c46f42acecac834371857e638098ebf6d27 Mon Sep 17 00:00:00 2001 From: zareck Date: Wed, 16 Aug 2023 14:09:00 -0300 Subject: [PATCH 3/3] Undo reordering and tmpl redirection --- modules/structs/repo.go | 16 ++-- services/convert/utils.go | 2 + services/convert/utils_test.go | 2 + templates/repo/migrate/forgejo.tmpl | 131 +--------------------------- 4 files changed, 13 insertions(+), 138 deletions(-) diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 461ad42ac7..dd119868e9 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -281,12 +281,12 @@ const ( PlainGitService // 1 plain git service GithubService // 2 github.com GiteaService // 3 gitea service - ForgejoService // 4 forgejo service - GitlabService // 5 gitlab service - GogsService // 6 gogs service - OneDevService // 7 onedev service - GitBucketService // 8 gitbucket service - CodebaseService // 9 codebase service + GitlabService // 4 gitlab service + GogsService // 5 gogs service + OneDevService // 6 onedev service + GitBucketService // 7 gitbucket service + CodebaseService // 8 codebase service + ForgejoService // 9 forgejo service ) // Name represents the service type's name @@ -302,8 +302,6 @@ func (gt GitServiceType) Title() string { return "GitHub" case GiteaService: return "Gitea" - case ForgejoService: - return "Forgejo" case GitlabService: return "GitLab" case GogsService: @@ -314,6 +312,8 @@ func (gt GitServiceType) Title() string { return "GitBucket" case CodebaseService: return "Codebase" + case ForgejoService: + return "Forgejo" case PlainGitService: return "Git" } diff --git a/services/convert/utils.go b/services/convert/utils.go index cdce60831c..fe35fd2dac 100644 --- a/services/convert/utils.go +++ b/services/convert/utils.go @@ -36,6 +36,8 @@ func ToGitServiceType(value string) structs.GitServiceType { return structs.OneDevService case "gitbucket": return structs.GitBucketService + case "forgejo": + return structs.ForgejoService default: return structs.PlainGitService } diff --git a/services/convert/utils_test.go b/services/convert/utils_test.go index 1ac03a3097..b464d8bb68 100644 --- a/services/convert/utils_test.go +++ b/services/convert/utils_test.go @@ -28,6 +28,8 @@ func TestToGitServiceType(t *testing.T) { typ: "gitlab", enum: 4, }, { typ: "gogs", enum: 5, + }, { + typ: "forgejo", enum: 9, }, { typ: "trash", enum: 1, }} diff --git a/templates/repo/migrate/forgejo.tmpl b/templates/repo/migrate/forgejo.tmpl index dd62e80479..3caadbee15 100644 --- a/templates/repo/migrate/forgejo.tmpl +++ b/templates/repo/migrate/forgejo.tmpl @@ -1,130 +1 @@ -{{template "base/head" .}} -
-
-
-
- {{.CsrfTokenHtml}} -

- {{.locale.Tr "repo.migrate.migrate" .service.Title}} - -

-
- {{template "base/alert" .}} -
- - - - {{.locale.Tr "repo.migrate.clone_address_desc"}}{{if .ContextUser.CanImportLocal}} {{.locale.Tr "repo.migrate.clone_local_path"}}{{end}} - -
- -
- - - -
- - {{template "repo/migrate/options" .}} - -
- -
- - -
-
- -
- {{.locale.Tr "repo.migrate.migrate_items_options"}} -
- -
- - -
-
- - -
-
-
- -
- - -
-
- -
- -
- -
- - -
- -
- - -
-
- -
- {{if .IsForcedPrivate}} - - - {{else}} - - - {{end}} -
-
-
- - -
- -
- - -
-
-
-
-
-
-{{template "base/footer" .}} +{{template "repo/migrate/gitea" .}}