Open sybrenstuvel opened 1 year ago
The fix is:
From 128e4f237cf952f9219f32bdfe86ffd40cec0f4c Mon Sep 17 00:00:00 2001
From: Matti-Ranta <matti-ranta@noreply.localhost>
Date: Wed, 21 Sep 2022 16:32:21 +0200
Subject: [PATCH] accept yaml for foreign_id
---
modules/migration/issue.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/migration/issue.go b/modules/migration/issue.go
index 78f648dd2..a23812eaf 100644
--- a/modules/migration/issue.go
+++ b/modules/migration/issue.go
@@ -25,7 +25,7 @@ type Issue struct {
Labels []*Label `json:"labels"`
Reactions []*Reaction `json:"reactions"`
Assignees []string `json:"assignees"`
- ForeignIndex int64 `json:"foreign_id"`
+ ForeignIndex int64 `yaml:"foreign_id" json:"foreign_id"`
Context DownloaderContext `yaml:"-"`
}
--
2.30.2
and
From 7620c236a86d9cd9771e805ca4ee18e56cb48ede Mon Sep 17 00:00:00 2001
From: Matti-Ranta <matti-ranta@noreply.localhost>
Date: Wed, 21 Sep 2022 16:24:01 +0200
Subject: [PATCH] if id is 0, then use local
---
services/migrations/gitea_uploader.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 21f587604..795ff4974 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -411,6 +411,10 @@ func (g *GiteaLocalUploader) CreateIssues(issues ...*base.Issue) error {
Type: foreignreference.TypeIssue,
},
}
+
+ if is.ForeignReference.ForeignIndex == "0" {
+ is.ForeignReference.ForeignIndex = strconv.FormatInt(is.Index, 10)
+ }
if err := g.remapUser(issue, &is); err != nil {
return err
--
2.30.2
The above will resolve the issue in 1.18, although foreign reference is removed in 1.19 (https://github.com/go-gitea/gitea/pull/21721)
Description
In short: the struct field
migration.Issue.ForeignIndex
is missing ayaml:"foreign_id"
annotation.When importing a dump from YAML files via
gitea restore-repo
, the "foreign ID" of an issue is used to load that issue's comments (seefunc (r *RepositoryRestorer) GetComments(...)
). On first glance this ID should be stored inissue.yml
in theforeign_id
field, but because there is only a JSON tag and not a YAML one, effectively Gitea is reading it fromforeignindex
.This issue was introduced in fa73cbf5a7e84fab50ad5c8f3095b4dec8b4e879. Where all the fields that should get an underscore in the name are annotated for both YAML and JSON, the
ForeignIndex
is not:Gitea Version
1.19.0+dev-289-gb36854df3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
2.34.1
Operating System
No response
How are you running Gitea?
Built Gitea myself from its
main
branch.Database
PostgreSQL