Skip to content

restore-repo: issue comments are no longer imported #22581

Closed
@drsybren

Description

@drsybren

Description

Since 71ca306 issue comments are no longer imported with gitea restore-repo.

See func (r *RepositoryRestorer) GetComments(...) in services/migrations/restore.go , it still uses commentable.GetForeignIndex() (link) but as far as I can see that foreign index isn't loaded any more since that commit.

This patches things up for me locally, but I don't know if this is the right thing to do:

diff --git a/services/migrations/restore.go b/services/migrations/restore.go
index fd337b22c..6ee878a64 100644
--- a/services/migrations/restore.go
+++ b/services/migrations/restore.go
@@ -198,7 +198,7 @@ func (r *RepositoryRestorer) GetIssues(page, perPage int) ([]*base.Issue, bool,
 // GetComments returns comments according issueNumber
 func (r *RepositoryRestorer) GetComments(commentable base.Commentable) ([]*base.Comment, bool, error) {
        comments := make([]*base.Comment, 0, 10)
-       p := filepath.Join(r.commentDir(), fmt.Sprintf("%d.yml", commentable.GetForeignIndex()))
+       p := filepath.Join(r.commentDir(), fmt.Sprintf("%d.yml", commentable.GetLocalIndex()))
        _, err := os.Stat(p)
        if err != nil {
                if os.IsNotExist(err) {

To reproduce the issue, unzip demo-repo-22581.zip, then run gitea restore-repo -r /path/to/demo-repo-22581 --owner_name youruser --repo_name demo-repo-22581

When visiting the repo in Gitea's web interface, you'll notice that there is one imported issue, but no comments, even though there is a corresponding file in demo-repo-22581/comment/104010.yml.

There's nothing about this in the logs.

Gitea Version

29b78bc

How are you running Gitea?

Self-built from the main branch.

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions