Skip to content

Commit

Permalink
Fix repo-restore bug with poster not replaced (go-gitea#14759)
Browse files Browse the repository at this point in the history
* Fix restore bug

* Fix restore bug

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
  • Loading branch information
4 people authored Feb 22, 2021
1 parent cd8b2f3 commit e79dae2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
27 changes: 18 additions & 9 deletions modules/migrations/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"time"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/migrations/base"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/structs"

"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -572,20 +574,27 @@ func RestoreRepository(ctx context.Context, baseDir string, ownerName, repoName
if err != nil {
return err
}
opts, err := downloader.getRepoOptions()
if err != nil {
return err
}
tp, _ := strconv.Atoi(opts["service_type"])

if err = migrateRepository(downloader, uploader, base.MigrateOptions{
Wiki: true,
Issues: true,
Milestones: true,
Labels: true,
Releases: true,
Comments: true,
PullRequests: true,
ReleaseAssets: true,
Wiki: true,
Issues: true,
Milestones: true,
Labels: true,
Releases: true,
Comments: true,
PullRequests: true,
ReleaseAssets: true,
GitServiceType: structs.GitServiceType(tp),
}); err != nil {
if err1 := uploader.Rollback(); err1 != nil {
log.Error("rollback failed: %v", err1)
}
return err
}
return nil
return updateMigrationPosterIDByGitService(ctx, structs.GitServiceType(tp))
}
12 changes: 10 additions & 2 deletions modules/migrations/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func (r *RepositoryRestorer) SetContext(ctx context.Context) {
r.ctx = ctx
}

// GetRepoInfo returns a repository information
func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error) {
func (r *RepositoryRestorer) getRepoOptions() (map[string]string, error) {
p := filepath.Join(r.baseDir, "repo.yml")
bs, err := ioutil.ReadFile(p)
if err != nil {
Expand All @@ -66,6 +65,15 @@ func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error) {
if err != nil {
return nil, err
}
return opts, nil
}

// GetRepoInfo returns a repository information
func (r *RepositoryRestorer) GetRepoInfo() (*base.Repository, error) {
opts, err := r.getRepoOptions()
if err != nil {
return nil, err
}

isPrivate, _ := strconv.ParseBool(opts["is_private"])

Expand Down

0 comments on commit e79dae2

Please sign in to comment.