Skip to content

Commit

Permalink
fix bug when migrating a private repository (go-gitea#7917)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and 6543 committed Oct 6, 2019
1 parent 5bac1a6 commit d69c489
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/migrations/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d69c489

Please sign in to comment.