fix: persist mirror repository metadata (#37519)

The migration repository model now carries Website alongside Description, the GitHub/Gitea downloaders populate it, and mirror finalization persists both description and website so the About section is not empty after creating a mirror.

Fixes #37495

---------

Signed-off-by: cyphercodes <cyphercodes@users.noreply.github.com>
Co-authored-by: cyphercodes <cyphercodes@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Rayan Salhab
2026-05-03 19:47:02 +03:00
committed by GitHub
parent 7016f7b37f
commit c4c50bee7f
12 changed files with 14 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ type Repository struct {
IsPrivate bool `yaml:"is_private"`
IsMirror bool `yaml:"is_mirror"`
Description string
Website string
CloneURL string `yaml:"clone_url"` // SECURITY: This must be checked to ensure that is safe to be used
OriginalURL string `yaml:"original_url"`
DefaultBranch string

View File

@@ -4,4 +4,4 @@ Content-Type: application/json;charset=utf-8
Vary: Origin
X-Content-Type-Options: nosniff
{"id":16268,"owner":{"id":3,"login":"gitea","login_name":"","source_id":0,"full_name":"","email":"","avatar_url":"https://gitea.com/avatars/35dea380390772b3130aafbac7ca49e6","html_url":"https://gitea.com/gitea","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-11-29T03:16:17Z","restricted":false,"active":false,"prohibit_login":false,"location":"Git Universe","website":"https://gitea.com","description":"Git with a cup of tea","visibility":"public","followers_count":100,"following_count":0,"starred_repos_count":0,"username":"gitea"},"name":"test_repo","full_name":"gitea/test_repo","description":"Test repository for testing migration from gitea to gitea","empty":false,"private":false,"fork":false,"template":false,"mirror":false,"size":68,"language":"","languages_url":"https://gitea.com/api/v1/repos/gitea/test_repo/languages","html_url":"https://gitea.com/gitea/test_repo","url":"https://gitea.com/api/v1/repos/gitea/test_repo","link":"","ssh_url":"git@gitea.com:gitea/test_repo.git","clone_url":"https://gitea.com/gitea/test_repo.git","original_url":"","website":"","stars_count":1,"forks_count":2,"watchers_count":10,"open_issues_count":2,"open_pr_counter":2,"release_counter":2,"default_branch":"master","archived":false,"created_at":"2020-09-01T00:12:27Z","updated_at":"2020-09-01T18:03:41Z","archived_at":"1970-01-01T00:00:00Z","permissions":{"admin":false,"push":false,"pull":true},"has_code":true,"has_issues":true,"internal_tracker":{"enable_time_tracker":true,"allow_only_contributors_to_track_time":true,"enable_issue_dependencies":true},"has_wiki":true,"has_pull_requests":true,"has_projects":true,"projects_mode":"","has_releases":true,"has_packages":false,"has_actions":false,"ignore_whitespace_conflicts":false,"allow_merge_commits":true,"allow_rebase":true,"allow_rebase_explicit":true,"allow_squash_merge":true,"allow_fast_forward_only_merge":false,"allow_rebase_update":true,"allow_manual_merge":false,"autodetect_manual_merge":false,"default_delete_branch_after_merge":false,"default_merge_style":"merge","default_allow_maintainer_edit":false,"avatar_url":"","internal":false,"mirror_interval":"","object_format_name":"sha1","mirror_updated":"0001-01-01T00:00:00Z","topics":["gitea","test","migration","ci"],"licenses":[]}
{"id":16268,"owner":{"id":3,"login":"gitea","login_name":"","source_id":0,"full_name":"","email":"","avatar_url":"https://gitea.com/avatars/35dea380390772b3130aafbac7ca49e6","html_url":"https://gitea.com/gitea","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-11-29T03:16:17Z","restricted":false,"active":false,"prohibit_login":false,"location":"Git Universe","website":"https://gitea.com","description":"Git with a cup of tea","visibility":"public","followers_count":100,"following_count":0,"starred_repos_count":0,"username":"gitea"},"name":"test_repo","full_name":"gitea/test_repo","description":"Test repository for testing migration from gitea to gitea","empty":false,"private":false,"fork":false,"template":false,"mirror":false,"size":68,"language":"","languages_url":"https://gitea.com/api/v1/repos/gitea/test_repo/languages","html_url":"https://gitea.com/gitea/test_repo","url":"https://gitea.com/api/v1/repos/gitea/test_repo","link":"","ssh_url":"git@gitea.com:gitea/test_repo.git","clone_url":"https://gitea.com/gitea/test_repo.git","original_url":"","website":"https://gitea.com/test-repo","stars_count":1,"forks_count":2,"watchers_count":10,"open_issues_count":2,"open_pr_counter":2,"release_counter":2,"default_branch":"master","archived":false,"created_at":"2020-09-01T00:12:27Z","updated_at":"2020-09-01T18:03:41Z","archived_at":"1970-01-01T00:00:00Z","permissions":{"admin":false,"push":false,"pull":true},"has_code":true,"has_issues":true,"internal_tracker":{"enable_time_tracker":true,"allow_only_contributors_to_track_time":true,"enable_issue_dependencies":true},"has_wiki":true,"has_pull_requests":true,"has_projects":true,"projects_mode":"","has_releases":true,"has_packages":false,"has_actions":false,"ignore_whitespace_conflicts":false,"allow_merge_commits":true,"allow_rebase":true,"allow_rebase_explicit":true,"allow_squash_merge":true,"allow_fast_forward_only_merge":false,"allow_rebase_update":true,"allow_manual_merge":false,"autodetect_manual_merge":false,"default_delete_branch_after_merge":false,"default_merge_style":"merge","default_allow_maintainer_edit":false,"avatar_url":"","internal":false,"mirror_interval":"","object_format_name":"sha1","mirror_updated":"0001-01-01T00:00:00Z","topics":["gitea","test","migration","ci"],"licenses":[]}

View File

@@ -115,6 +115,7 @@ func (g *RepositoryDumper) CreateRepo(ctx context.Context, repo *base.Repository
"name": repo.Name,
"owner": repo.Owner,
"description": repo.Description,
"website": repo.Website,
"clone_addr": opts.CloneAddr,
"original_url": repo.OriginalURL,
"is_private": opts.Private,

View File

@@ -150,6 +150,7 @@ func (g *GiteaDownloader) GetRepoInfo(_ context.Context) (*base.Repository, erro
Owner: repo.Owner.UserName,
IsPrivate: repo.Private,
Description: repo.Description,
Website: repo.Website,
CloneURL: repo.CloneURL,
OriginalURL: repo.HTMLURL,
DefaultBranch: repo.DefaultBranch,

View File

@@ -38,6 +38,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
Owner: "gitea",
IsPrivate: false,
Description: "Test repository for testing migration from gitea to gitea",
Website: mockServer.URL + "/test-repo",
CloneURL: mockServer.URL + "/gitea/test_repo.git",
OriginalURL: mockServer.URL + "/gitea/test_repo",
DefaultBranch: "master",

View File

@@ -101,6 +101,7 @@ func (g *GiteaLocalUploader) CreateRepo(ctx context.Context, repo *base.Reposito
r, err = repo_service.CreateRepositoryDirectly(ctx, g.doer, owner, repo_service.CreateRepoOptions{
Name: g.repoName,
Description: repo.Description,
Website: repo.Website,
OriginalURL: repo.OriginalURL,
GitServiceType: opts.GitServiceType,
IsPrivate: opts.Private || setting.Repository.ForcePrivate,
@@ -115,6 +116,7 @@ func (g *GiteaLocalUploader) CreateRepo(ctx context.Context, repo *base.Reposito
}
r.DefaultBranch = repo.DefaultBranch
r.Description = repo.Description
r.Website = repo.Website
r, err = repo_service.MigrateRepositoryGitData(ctx, owner, r, base.MigrateOptions{
RepoName: g.repoName,

View File

@@ -205,6 +205,7 @@ func (g *GithubDownloaderV3) GetRepoInfo(ctx context.Context) (*base.Repository,
Name: gr.GetName(),
IsPrivate: gr.GetPrivate(),
Description: gr.GetDescription(),
Website: gr.GetHomepage(),
OriginalURL: gr.GetHTMLURL(),
CloneURL: gr.GetCloneURL(),
DefaultBranch: gr.GetDefaultBranch(),

View File

@@ -40,6 +40,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
Name: "test_repo",
Owner: "go-gitea",
Description: "Test repository for testing migration from github to gitea",
Website: "https://gitea.com/test-repo",
CloneURL: "https://github.com/go-gitea/test_repo.git",
OriginalURL: "https://github.com/go-gitea/test_repo",
DefaultBranch: "master",

View File

@@ -210,6 +210,7 @@ func assertRepositoryEqual(t *testing.T, expected, actual *base.Repository) {
assert.Equal(t, expected.IsPrivate, actual.IsPrivate)
assert.Equal(t, expected.IsMirror, actual.IsMirror)
assert.Equal(t, expected.Description, actual.Description)
assert.Equal(t, expected.Website, actual.Website)
assert.Equal(t, expected.CloneURL, actual.CloneURL)
assert.Equal(t, expected.OriginalURL, actual.OriginalURL)
assert.Equal(t, expected.DefaultBranch, actual.DefaultBranch)

View File

@@ -75,6 +75,7 @@ func (r *RepositoryRestorer) GetRepoInfo(_ context.Context) (*base.Repository, e
Name: r.repoName,
IsPrivate: isPrivate,
Description: opts["description"],
Website: opts["website"],
OriginalURL: opts["original_url"],
CloneURL: filepath.Join(r.baseDir, "git"),
DefaultBranch: opts["default_branch"],

View File

@@ -38,6 +38,7 @@ import (
type CreateRepoOptions struct {
Name string
Description string
Website string
OriginalURL string
GitServiceType api.GitServiceType
Gitignores string
@@ -242,6 +243,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
Name: opts.Name,
LowerName: strings.ToLower(opts.Name),
Description: opts.Description,
Website: opts.Website,
OriginalURL: opts.OriginalURL,
OriginalServiceType: opts.GitServiceType,
IsPrivate: opts.IsPrivate,