Backport Migration Option AuthToken (#13101)

fix #13085

Backport #12862
Backport Parts of #12672
This commit is contained in:
6543 2020-10-12 08:14:02 +02:00 committed by GitHub
parent d4af0df967
commit f9942add50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 33 deletions

View file

@ -93,12 +93,15 @@ func (g *GiteaLocalUploader) CreateRepo(repo *base.Repository, opts base.Migrate
}
var remoteAddr = repo.CloneURL
if len(opts.AuthUsername) > 0 {
if len(opts.AuthToken) > 0 || len(opts.AuthUsername) > 0 {
u, err := url.Parse(repo.CloneURL)
if err != nil {
return err
}
u.User = url.UserPassword(opts.AuthUsername, opts.AuthPassword)
if len(opts.AuthToken) > 0 {
u.User = url.UserPassword("oauth2", opts.AuthToken)
}
remoteAddr = u.String()
}