From 3a749fc816ed2957527bd9529e688adf84dadecf Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Tue, 14 Jan 2025 15:29:44 +0900 Subject: [PATCH] Fix 500 error when error occurred in migration page (#33256) The template should be `repo/migrate/{service type}` But input element `service` is not in the form. Related: #33081 --------- Co-authored-by: wxiaoguang --- templates/repo/migrate/codebase.tmpl | 4 +++- templates/repo/migrate/codecommit.tmpl | 4 +++- templates/repo/migrate/git.tmpl | 4 +++- templates/repo/migrate/gitbucket.tmpl | 4 +++- templates/repo/migrate/gitea.tmpl | 4 +++- templates/repo/migrate/github.tmpl | 4 +++- templates/repo/migrate/gitlab.tmpl | 4 +++- templates/repo/migrate/gogs.tmpl | 4 +++- templates/repo/migrate/onedev.tmpl | 4 +++- tests/integration/migrate_test.go | 6 +++++- 10 files changed, 32 insertions(+), 10 deletions(-) diff --git a/templates/repo/migrate/codebase.tmpl b/templates/repo/migrate/codebase.tmpl index 35f3614ec5..d4ca269f02 100644 --- a/templates/repo/migrate/codebase.tmpl +++ b/templates/repo/migrate/codebase.tmpl @@ -3,13 +3,15 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}}
{{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/codecommit.tmpl b/templates/repo/migrate/codecommit.tmpl index f75112f896..53ca7dda3d 100644 --- a/templates/repo/migrate/codecommit.tmpl +++ b/templates/repo/migrate/codecommit.tmpl @@ -3,13 +3,15 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/git.tmpl b/templates/repo/migrate/git.tmpl index b10c49c10e..3f447f76eb 100644 --- a/templates/repo/migrate/git.tmpl +++ b/templates/repo/migrate/git.tmpl @@ -3,13 +3,15 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/gitbucket.tmpl b/templates/repo/migrate/gitbucket.tmpl index 80d2491e91..559988951b 100644 --- a/templates/repo/migrate/gitbucket.tmpl +++ b/templates/repo/migrate/gitbucket.tmpl @@ -3,13 +3,15 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/gitea.tmpl b/templates/repo/migrate/gitea.tmpl index 220295662e..3d692129d5 100644 --- a/templates/repo/migrate/gitea.tmpl +++ b/templates/repo/migrate/gitea.tmpl @@ -3,12 +3,14 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/github.tmpl b/templates/repo/migrate/github.tmpl index d1aa4c1f29..850a2b3c71 100644 --- a/templates/repo/migrate/github.tmpl +++ b/templates/repo/migrate/github.tmpl @@ -3,12 +3,14 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/gitlab.tmpl b/templates/repo/migrate/gitlab.tmpl index 87a04d7849..9bafa122f1 100644 --- a/templates/repo/migrate/gitlab.tmpl +++ b/templates/repo/migrate/gitlab.tmpl @@ -3,12 +3,14 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/gogs.tmpl b/templates/repo/migrate/gogs.tmpl index a4d05e8acd..0495ce67fb 100644 --- a/templates/repo/migrate/gogs.tmpl +++ b/templates/repo/migrate/gogs.tmpl @@ -3,12 +3,14 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{.CsrfTokenHtml}} + + +
diff --git a/templates/repo/migrate/onedev.tmpl b/templates/repo/migrate/onedev.tmpl index a27188ed24..55945154ef 100644 --- a/templates/repo/migrate/onedev.tmpl +++ b/templates/repo/migrate/onedev.tmpl @@ -3,13 +3,15 @@

{{ctx.Locale.Tr "repo.migrate.migrate" .service.Title}} -

{{template "base/alert" .}} {{template "base/disable_form_autofill"}} {{.CsrfTokenHtml}} + + +
diff --git a/tests/integration/migrate_test.go b/tests/integration/migrate_test.go index 4c784dd22b..59dd6907db 100644 --- a/tests/integration/migrate_test.go +++ b/tests/integration/migrate_test.go @@ -79,8 +79,12 @@ func TestMigrateGiteaForm(t *testing.T) { resp := session.MakeRequest(t, req, http.StatusOK) // Step 2: load the form htmlDoc := NewHTMLParser(t, resp.Body) - link, exists := htmlDoc.doc.Find(`form.ui.form[action^="/repo/migrate"]`).Attr("action") + form := htmlDoc.doc.Find(`form.ui.form[action^="/repo/migrate"]`) + link, exists := form.Attr("action") assert.True(t, exists, "The template has changed") + serviceInput, exists := form.Find(`input[name="service"]`).Attr("value") + assert.True(t, exists) + assert.EqualValues(t, fmt.Sprintf("%d", structs.GiteaService), serviceInput) // Step 4: submit the migration to only migrate issues migratedRepoName := "otherrepo" req = NewRequestWithValues(t, "POST", link, map[string]string{