@ -125,7 +125,7 @@ func MigrateRepository(ctx context.Context, doer *user_model.User, ownerName str
uploader := NewGiteaLocalUploader ( ctx , doer , ownerName , opts . RepoName )
uploader := NewGiteaLocalUploader ( ctx , doer , ownerName , opts . RepoName )
uploader . gitServiceType = opts . GitServiceType
uploader . gitServiceType = opts . GitServiceType
if err := migrateRepository ( downloader , uploader , opts , messenger ) ; err != nil {
if err := migrateRepository ( doer , do wnloader , uploader , opts , messenger ) ; err != nil {
if err1 := uploader . Rollback ( ) ; err1 != nil {
if err1 := uploader . Rollback ( ) ; err1 != nil {
log . Error ( "rollback failed: %v" , err1 )
log . Error ( "rollback failed: %v" , err1 )
}
}
@ -174,7 +174,7 @@ func newDownloader(ctx context.Context, ownerName string, opts base.MigrateOptio
// migrateRepository will download information and then upload it to Uploader, this is a simple
// migrateRepository will download information and then upload it to Uploader, this is a simple
// process for small repository. For a big repository, save all the data to disk
// process for small repository. For a big repository, save all the data to disk
// before upload is better
// before upload is better
func migrateRepository ( downloader base . Downloader , uploader base . Uploader , opts base . MigrateOptions , messenger base . Messenger ) error {
func migrateRepository ( doer * user_model . User , do wnloader base . Downloader , uploader base . Uploader , opts base . MigrateOptions , messenger base . Messenger ) error {
if messenger == nil {
if messenger == nil {
messenger = base . NilMessenger
messenger = base . NilMessenger
}
}
@ -195,6 +195,21 @@ func migrateRepository(downloader base.Downloader, uploader base.Uploader, opts
return err
return err
}
}
// If the downloader is not a RepositoryRestorer then we need to recheck the CloneURL
if _ , ok := downloader . ( * RepositoryRestorer ) ; ! ok {
// Now the clone URL can be rewritten by the downloader so we must recheck
if err := IsMigrateURLAllowed ( repo . CloneURL , doer ) ; err != nil {
return err
}
// And so can the original URL too so again we must recheck
if repo . OriginalURL != "" {
if err := IsMigrateURLAllowed ( repo . OriginalURL , doer ) ; err != nil {
return err
}
}
}
log . Trace ( "migrating git data from %s" , repo . CloneURL )
log . Trace ( "migrating git data from %s" , repo . CloneURL )
messenger ( "repo.migrate.migrating_git" )
messenger ( "repo.migrate.migrating_git" )
if err = uploader . CreateRepo ( repo , opts ) ; err != nil {
if err = uploader . CreateRepo ( repo , opts ) ; err != nil {