mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-20 17:55:42 +02:00
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:
parent
7016f7b37f
commit
c4c50bee7f
@ -11,6 +11,7 @@ type Repository struct {
|
|||||||
IsPrivate bool `yaml:"is_private"`
|
IsPrivate bool `yaml:"is_private"`
|
||||||
IsMirror bool `yaml:"is_mirror"`
|
IsMirror bool `yaml:"is_mirror"`
|
||||||
Description string
|
Description string
|
||||||
|
Website string
|
||||||
CloneURL string `yaml:"clone_url"` // SECURITY: This must be checked to ensure that is safe to be used
|
CloneURL string `yaml:"clone_url"` // SECURITY: This must be checked to ensure that is safe to be used
|
||||||
OriginalURL string `yaml:"original_url"`
|
OriginalURL string `yaml:"original_url"`
|
||||||
DefaultBranch string
|
DefaultBranch string
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -4,4 +4,4 @@ Content-Type: application/json;charset=utf-8
|
|||||||
Vary: Origin
|
Vary: Origin
|
||||||
X-Content-Type-Options: nosniff
|
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":[]}
|
||||||
@ -115,6 +115,7 @@ func (g *RepositoryDumper) CreateRepo(ctx context.Context, repo *base.Repository
|
|||||||
"name": repo.Name,
|
"name": repo.Name,
|
||||||
"owner": repo.Owner,
|
"owner": repo.Owner,
|
||||||
"description": repo.Description,
|
"description": repo.Description,
|
||||||
|
"website": repo.Website,
|
||||||
"clone_addr": opts.CloneAddr,
|
"clone_addr": opts.CloneAddr,
|
||||||
"original_url": repo.OriginalURL,
|
"original_url": repo.OriginalURL,
|
||||||
"is_private": opts.Private,
|
"is_private": opts.Private,
|
||||||
|
|||||||
@ -150,6 +150,7 @@ func (g *GiteaDownloader) GetRepoInfo(_ context.Context) (*base.Repository, erro
|
|||||||
Owner: repo.Owner.UserName,
|
Owner: repo.Owner.UserName,
|
||||||
IsPrivate: repo.Private,
|
IsPrivate: repo.Private,
|
||||||
Description: repo.Description,
|
Description: repo.Description,
|
||||||
|
Website: repo.Website,
|
||||||
CloneURL: repo.CloneURL,
|
CloneURL: repo.CloneURL,
|
||||||
OriginalURL: repo.HTMLURL,
|
OriginalURL: repo.HTMLURL,
|
||||||
DefaultBranch: repo.DefaultBranch,
|
DefaultBranch: repo.DefaultBranch,
|
||||||
|
|||||||
@ -38,6 +38,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
|
|||||||
Owner: "gitea",
|
Owner: "gitea",
|
||||||
IsPrivate: false,
|
IsPrivate: false,
|
||||||
Description: "Test repository for testing migration from gitea to gitea",
|
Description: "Test repository for testing migration from gitea to gitea",
|
||||||
|
Website: mockServer.URL + "/test-repo",
|
||||||
CloneURL: mockServer.URL + "/gitea/test_repo.git",
|
CloneURL: mockServer.URL + "/gitea/test_repo.git",
|
||||||
OriginalURL: mockServer.URL + "/gitea/test_repo",
|
OriginalURL: mockServer.URL + "/gitea/test_repo",
|
||||||
DefaultBranch: "master",
|
DefaultBranch: "master",
|
||||||
|
|||||||
@ -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{
|
r, err = repo_service.CreateRepositoryDirectly(ctx, g.doer, owner, repo_service.CreateRepoOptions{
|
||||||
Name: g.repoName,
|
Name: g.repoName,
|
||||||
Description: repo.Description,
|
Description: repo.Description,
|
||||||
|
Website: repo.Website,
|
||||||
OriginalURL: repo.OriginalURL,
|
OriginalURL: repo.OriginalURL,
|
||||||
GitServiceType: opts.GitServiceType,
|
GitServiceType: opts.GitServiceType,
|
||||||
IsPrivate: opts.Private || setting.Repository.ForcePrivate,
|
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.DefaultBranch = repo.DefaultBranch
|
||||||
r.Description = repo.Description
|
r.Description = repo.Description
|
||||||
|
r.Website = repo.Website
|
||||||
|
|
||||||
r, err = repo_service.MigrateRepositoryGitData(ctx, owner, r, base.MigrateOptions{
|
r, err = repo_service.MigrateRepositoryGitData(ctx, owner, r, base.MigrateOptions{
|
||||||
RepoName: g.repoName,
|
RepoName: g.repoName,
|
||||||
|
|||||||
@ -205,6 +205,7 @@ func (g *GithubDownloaderV3) GetRepoInfo(ctx context.Context) (*base.Repository,
|
|||||||
Name: gr.GetName(),
|
Name: gr.GetName(),
|
||||||
IsPrivate: gr.GetPrivate(),
|
IsPrivate: gr.GetPrivate(),
|
||||||
Description: gr.GetDescription(),
|
Description: gr.GetDescription(),
|
||||||
|
Website: gr.GetHomepage(),
|
||||||
OriginalURL: gr.GetHTMLURL(),
|
OriginalURL: gr.GetHTMLURL(),
|
||||||
CloneURL: gr.GetCloneURL(),
|
CloneURL: gr.GetCloneURL(),
|
||||||
DefaultBranch: gr.GetDefaultBranch(),
|
DefaultBranch: gr.GetDefaultBranch(),
|
||||||
|
|||||||
@ -40,6 +40,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
|
|||||||
Name: "test_repo",
|
Name: "test_repo",
|
||||||
Owner: "go-gitea",
|
Owner: "go-gitea",
|
||||||
Description: "Test repository for testing migration from github to 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",
|
CloneURL: "https://github.com/go-gitea/test_repo.git",
|
||||||
OriginalURL: "https://github.com/go-gitea/test_repo",
|
OriginalURL: "https://github.com/go-gitea/test_repo",
|
||||||
DefaultBranch: "master",
|
DefaultBranch: "master",
|
||||||
|
|||||||
@ -210,6 +210,7 @@ func assertRepositoryEqual(t *testing.T, expected, actual *base.Repository) {
|
|||||||
assert.Equal(t, expected.IsPrivate, actual.IsPrivate)
|
assert.Equal(t, expected.IsPrivate, actual.IsPrivate)
|
||||||
assert.Equal(t, expected.IsMirror, actual.IsMirror)
|
assert.Equal(t, expected.IsMirror, actual.IsMirror)
|
||||||
assert.Equal(t, expected.Description, actual.Description)
|
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.CloneURL, actual.CloneURL)
|
||||||
assert.Equal(t, expected.OriginalURL, actual.OriginalURL)
|
assert.Equal(t, expected.OriginalURL, actual.OriginalURL)
|
||||||
assert.Equal(t, expected.DefaultBranch, actual.DefaultBranch)
|
assert.Equal(t, expected.DefaultBranch, actual.DefaultBranch)
|
||||||
|
|||||||
@ -75,6 +75,7 @@ func (r *RepositoryRestorer) GetRepoInfo(_ context.Context) (*base.Repository, e
|
|||||||
Name: r.repoName,
|
Name: r.repoName,
|
||||||
IsPrivate: isPrivate,
|
IsPrivate: isPrivate,
|
||||||
Description: opts["description"],
|
Description: opts["description"],
|
||||||
|
Website: opts["website"],
|
||||||
OriginalURL: opts["original_url"],
|
OriginalURL: opts["original_url"],
|
||||||
CloneURL: filepath.Join(r.baseDir, "git"),
|
CloneURL: filepath.Join(r.baseDir, "git"),
|
||||||
DefaultBranch: opts["default_branch"],
|
DefaultBranch: opts["default_branch"],
|
||||||
|
|||||||
@ -38,6 +38,7 @@ import (
|
|||||||
type CreateRepoOptions struct {
|
type CreateRepoOptions struct {
|
||||||
Name string
|
Name string
|
||||||
Description string
|
Description string
|
||||||
|
Website string
|
||||||
OriginalURL string
|
OriginalURL string
|
||||||
GitServiceType api.GitServiceType
|
GitServiceType api.GitServiceType
|
||||||
Gitignores string
|
Gitignores string
|
||||||
@ -242,6 +243,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
|
|||||||
Name: opts.Name,
|
Name: opts.Name,
|
||||||
LowerName: strings.ToLower(opts.Name),
|
LowerName: strings.ToLower(opts.Name),
|
||||||
Description: opts.Description,
|
Description: opts.Description,
|
||||||
|
Website: opts.Website,
|
||||||
OriginalURL: opts.OriginalURL,
|
OriginalURL: opts.OriginalURL,
|
||||||
OriginalServiceType: opts.GitServiceType,
|
OriginalServiceType: opts.GitServiceType,
|
||||||
IsPrivate: opts.IsPrivate,
|
IsPrivate: opts.IsPrivate,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user