Skip to content

Commit 7cbcb62

Browse files
committed
fix
1 parent 50111c7 commit 7cbcb62

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

modules/migration/comment.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import "time"
88

99
// Commentable can be commented upon
1010
type Commentable interface {
11-
GetLocalIndex() int64
12-
GetForeignIndex() int64
11+
Reviewable
1312
GetContext() DownloaderContext
1413
}
1514

modules/migration/issue.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ func (issue *Issue) GetExternalName() string { return issue.PosterName }
3434
// GetExternalID ExternalUserMigrated interface
3535
func (issue *Issue) GetExternalID() int64 { return issue.PosterID }
3636

37-
func (issue *Issue) GetLocalIndex() int64 { return issue.Number }
38-
func (issue *Issue) GetForeignIndex() int64 { return issue.ForeignIndex }
37+
func (issue *Issue) GetLocalIndex() int64 { return issue.Number }
38+
39+
func (issue *Issue) GetForeignIndex() int64 {
40+
// see the comment of Reviewable.GetForeignIndex
41+
// if there is no ForeignIndex, then use LocalIndex
42+
if issue.ForeignIndex == 0 {
43+
return issue.Number
44+
}
45+
return issue.ForeignIndex
46+
}
47+
3948
func (issue *Issue) GetContext() DownloaderContext { return issue.Context }

modules/migration/review.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ import "time"
88
// Reviewable can be reviewed
99
type Reviewable interface {
1010
GetLocalIndex() int64
11+
12+
// GetForeignIndex presents the foreign index, which could be misused:
13+
// For example, if there are 2 Gitea sites: site-A exports a dataset, then site-B imports it:
14+
// * if site-A exports files by using its LocalIndex
15+
// * from site-A's view, LocalIndex is site-A's IssueIndex while ForeignIndex is site-B's IssueIndex
16+
// * but from site-B's view, LocalIndex is site-B's IssueIndex while ForeignIndex is site-A's IssueIndex
17+
//
18+
// So the exporting/importing must be paired, but the meaning of them looks confusing then:
19+
// * either site-A and site-B both use LocalIndex during dumping/restoring
20+
// * or site-A and site-B both use ForeignIndex
1121
GetForeignIndex() int64
1222
}
1323

@@ -37,7 +47,7 @@ type Review struct {
3747
// GetExternalName ExternalUserMigrated interface
3848
func (r *Review) GetExternalName() string { return r.ReviewerName }
3949

40-
// ExternalID ExternalUserMigrated interface
50+
// GetExternalID ExternalUserMigrated interface
4151
func (r *Review) GetExternalID() int64 { return r.ReviewerID }
4252

4353
// ReviewComment represents a review comment

0 commit comments

Comments
 (0)