diff options
author | 6543 | 2019-10-07 06:58:35 +0200 |
---|---|---|
committer | techknowlogick | 2019-10-07 00:58:35 -0400 |
commit | 30718ce4ac7762dfe428ff6fac598ace45be50c9 (patch) | |
tree | 4572532e82a0653218d771ff3cd68efcccf3a5d3 | |
parent | aeec78543bf415dc1e75a121cbc0c1430c05c683 (diff) |
fix bug when migrating a private repository (#7917) (#8403)
-rw-r--r-- | modules/migrations/gitea.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/migrations/gitea.go b/modules/migrations/gitea.go index dc395a779..374e4b34d 100644 --- a/modules/migrations/gitea.go +++ b/modules/migrations/gitea.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "net/http" + "net/url" "os" "path" "path/filepath" @@ -79,11 +80,21 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate return err } + var remoteAddr = repo.CloneURL + if len(opts.AuthUsername) > 0 { + u, err := url.Parse(repo.CloneURL) + if err != nil { + return err + } + u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword) + remoteAddr = u.String() + } + r, err := models.MigrateRepository(g.doer, owner, models.MigrateRepoOptions{ Name: g.repoName, Description: repo.Description, IsMirror: repo.IsMirror, - RemoteAddr: repo.CloneURL, + RemoteAddr: remoteAddr, IsPrivate: repo.IsPrivate, Wiki: opts.Wiki, SyncReleasesWithTags: !opts.Releases, // if didn't get releases, then sync them from tags |