summaryrefslogtreecommitdiffstats
path: root/services/migrations
diff options
context:
space:
mode:
authorsinguliere <35190819+singuliere@users.noreply.github.com>2022-03-06 20:00:41 +0100
committerGitHub <noreply@github.com>2022-03-06 20:00:41 +0100
commitcc643284de106a609b4ac03ed2a7f615ab6d312a (patch)
tree8fa1a70d658a6185d4e7cdcef80000cc47e81e74 /services/migrations
parentb24e8d38af21fc1857b6aa66351627e3b1761608 (diff)
downloadgitea-cc643284de106a609b4ac03ed2a7f615ab6d312a.tar.gz
gitea-cc643284de106a609b4ac03ed2a7f615ab6d312a.zip
Add Index to comment for migrations and mirroring (#18806)
Comments have an id (see Gitea[0], GitLab[1], GitHub[2], etc.), and the comment migration format must represent it during migrations so that it can be used during mirroring or incremental migrations. [0] https://try.gitea.io/api/swagger#/issue/issueGetComment [1] https://docs.gitlab.com/ee/api/discussions.html#get-single-issue-discussion-item [2] https://docs.github.com/en/rest/reference/issues#get-an-issue-comment Signed-off-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Loïc Dachary <loic@dachary.org>
Diffstat (limited to 'services/migrations')
-rw-r--r--services/migrations/codebase.go8
-rw-r--r--services/migrations/gitea_downloader.go1
-rw-r--r--services/migrations/github.go2
-rw-r--r--services/migrations/gitlab.go2
-rw-r--r--services/migrations/gogs.go1
-rw-r--r--services/migrations/onedev.go2
6 files changed, 15 insertions, 1 deletions
diff --git a/services/migrations/codebase.go b/services/migrations/codebase.go
index 13e9327c33..be0b5d4004 100644
--- a/services/migrations/codebase.go
+++ b/services/migrations/codebase.go
@@ -371,6 +371,7 @@ func (d *CodebaseDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool,
poster := d.tryGetUser(note.UserID.Value)
comments = append(comments, &base.Comment{
IssueIndex: issue.TicketID.Value,
+ Index: note.ID.Value,
PosterID: poster.ID,
PosterName: poster.Name,
PosterEmail: poster.Email,
@@ -481,7 +482,11 @@ func (d *CodebaseDownloader) GetPullRequests(page, perPage int) ([]*base.PullReq
Type string `xml:"type,attr"`
Comment []struct {
Content string `xml:"content"`
- UserID struct {
+ ID struct {
+ Value int64 `xml:",chardata"`
+ Type string `xml:"type,attr"`
+ } `xml:"id"`
+ UserID struct {
Value int64 `xml:",chardata"`
Type string `xml:"type,attr"`
} `xml:"user-id"`
@@ -528,6 +533,7 @@ func (d *CodebaseDownloader) GetPullRequests(page, perPage int) ([]*base.PullReq
poster := d.tryGetUser(comment.UserID.Value)
comments = append(comments, &base.Comment{
IssueIndex: number,
+ Index: comment.ID.Value,
PosterID: poster.ID,
PosterName: poster.Name,
PosterEmail: poster.Email,
diff --git a/services/migrations/gitea_downloader.go b/services/migrations/gitea_downloader.go
index a712b65a22..be3c6c1202 100644
--- a/services/migrations/gitea_downloader.go
+++ b/services/migrations/gitea_downloader.go
@@ -473,6 +473,7 @@ func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comm
allComments = append(allComments, &base.Comment{
IssueIndex: opts.Context.LocalID(),
+ Index: comment.ID,
PosterID: comment.Poster.ID,
PosterName: comment.Poster.UserName,
PosterEmail: comment.Poster.Email,
diff --git a/services/migrations/github.go b/services/migrations/github.go
index a946177c90..f86ba94393 100644
--- a/services/migrations/github.go
+++ b/services/migrations/github.go
@@ -532,6 +532,7 @@ func (g *GithubDownloaderV3) getComments(issueContext base.IssueContext) ([]*bas
allComments = append(allComments, &base.Comment{
IssueIndex: issueContext.LocalID(),
+ Index: comment.GetID(),
PosterID: comment.GetUser().GetID(),
PosterName: comment.GetUser().GetLogin(),
PosterEmail: comment.GetUser().GetEmail(),
@@ -607,6 +608,7 @@ func (g *GithubDownloaderV3) GetAllComments(page, perPage int) ([]*base.Comment,
issueIndex, _ := strconv.ParseInt((*comment.IssueURL)[idx+1:], 10, 64)
allComments = append(allComments, &base.Comment{
IssueIndex: issueIndex,
+ Index: comment.GetID(),
PosterID: comment.GetUser().GetID(),
PosterName: comment.GetUser().GetLogin(),
PosterEmail: comment.GetUser().GetEmail(),
diff --git a/services/migrations/gitlab.go b/services/migrations/gitlab.go
index 97ebc4dd8b..c05d081e9a 100644
--- a/services/migrations/gitlab.go
+++ b/services/migrations/gitlab.go
@@ -485,6 +485,7 @@ func (g *GitlabDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Com
for _, note := range comment.Notes {
allComments = append(allComments, &base.Comment{
IssueIndex: context.LocalID(),
+ Index: int64(note.ID),
PosterID: int64(note.Author.ID),
PosterName: note.Author.Username,
PosterEmail: note.Author.Email,
@@ -496,6 +497,7 @@ func (g *GitlabDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Com
c := comment.Notes[0]
allComments = append(allComments, &base.Comment{
IssueIndex: context.LocalID(),
+ Index: int64(c.ID),
PosterID: int64(c.Author.ID),
PosterName: c.Author.Username,
PosterEmail: c.Author.Email,
diff --git a/services/migrations/gogs.go b/services/migrations/gogs.go
index 9280427cd7..0ef39484b7 100644
--- a/services/migrations/gogs.go
+++ b/services/migrations/gogs.go
@@ -236,6 +236,7 @@ func (g *GogsDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comme
}
allComments = append(allComments, &base.Comment{
IssueIndex: opts.Context.LocalID(),
+ Index: comment.ID,
PosterID: comment.Poster.ID,
PosterName: comment.Poster.Login,
PosterEmail: comment.Poster.Email,
diff --git a/services/migrations/onedev.go b/services/migrations/onedev.go
index c8253e8947..d27cbbed4f 100644
--- a/services/migrations/onedev.go
+++ b/services/migrations/onedev.go
@@ -379,6 +379,7 @@ func (d *OneDevDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Com
}
rawComments := make([]struct {
+ ID int64 `json:"id"`
Date time.Time `json:"date"`
UserID int64 `json:"userId"`
Content string `json:"content"`
@@ -429,6 +430,7 @@ func (d *OneDevDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Com
poster := d.tryGetUser(comment.UserID)
comments = append(comments, &base.Comment{
IssueIndex: context.LocalID(),
+ Index: comment.ID,
PosterID: poster.ID,
PosterName: poster.Name,
PosterEmail: poster.Email,