diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-05-07 09:12:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 09:12:51 +0800 |
commit | 08069dc4656fa53ee5dd25189e15012cb4f8acb2 (patch) | |
tree | 2e08cb239fef3221e55da75f106dfcb0140e08a1 /models/repo.go | |
parent | 1c7c739eb9ea1d2ffdaed3c776c84d42858c0851 (diff) | |
download | gitea-08069dc4656fa53ee5dd25189e15012cb4f8acb2.tar.gz gitea-08069dc4656fa53ee5dd25189e15012cb4f8acb2.zip |
Improve migrations to support migrating milestones/labels/issues/comments/pullrequests (#6290)
* add migrations
* fix package dependency
* fix lints
* implements migrations except pull requests
* add releases
* migrating releases
* fix bug
* fix lint
* fix migrate releases
* fix tests
* add rollback
* pull request migtations
* fix import
* fix go module vendor
* add tests for upload to gitea
* more migrate options
* fix swagger-check
* fix misspell
* add options on migration UI
* fix log error
* improve UI options on migrating
* add support for username password when migrating from github
* fix tests
* remove comments and fix migrate limitation
* improve error handles
* migrate API will also support migrate milestones/labels/issues/pulls/releases
* fix tests and remove unused codes
* add DownloaderFactory and docs about how to create a new Downloader
* fix misspell
* fix migration docs
* Add hints about migrate options on migration page
* fix tests
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/models/repo.go b/models/repo.go index 936ad2ae37..e8af9aa2db 100644 --- a/models/repo.go +++ b/models/repo.go @@ -896,6 +896,7 @@ type MigrateRepoOptions struct { IsPrivate bool IsMirror bool RemoteAddr string + Wiki bool // include wiki repository } /* @@ -917,7 +918,7 @@ func wikiRemoteURL(remote string) string { return "" } -// MigrateRepository migrates a existing repository from other project hosting. +// MigrateRepository migrates an existing repository from other project hosting. func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, error) { repo, err := CreateRepository(doer, u, CreateRepoOptions{ Name: opts.Name, @@ -930,7 +931,6 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err } repoPath := RepoPath(u.Name, opts.Name) - wikiPath := WikiPath(u.Name, opts.Name) if u.IsOrganization() { t, err := u.GetOwnerTeam() @@ -956,22 +956,25 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err return repo, fmt.Errorf("Clone: %v", err) } - wikiRemotePath := wikiRemoteURL(opts.RemoteAddr) - if len(wikiRemotePath) > 0 { - if err := os.RemoveAll(wikiPath); err != nil { - return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err) - } - - if err = git.Clone(wikiRemotePath, wikiPath, git.CloneRepoOptions{ - Mirror: true, - Quiet: true, - Timeout: migrateTimeout, - Branch: "master", - }); err != nil { - log.Warn("Clone wiki: %v", err) + if opts.Wiki { + wikiPath := WikiPath(u.Name, opts.Name) + wikiRemotePath := wikiRemoteURL(opts.RemoteAddr) + if len(wikiRemotePath) > 0 { if err := os.RemoveAll(wikiPath); err != nil { return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err) } + + if err = git.Clone(wikiRemotePath, wikiPath, git.CloneRepoOptions{ + Mirror: true, + Quiet: true, + Timeout: migrateTimeout, + Branch: "master", + }); err != nil { + log.Warn("Clone wiki: %v", err) + if err := os.RemoveAll(wikiPath); err != nil { + return repo, fmt.Errorf("Failed to remove %s: %v", wikiPath, err) + } + } } } |