Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate reactions when migrating repository from github #9599

Merged
merged 9 commits into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
lunny committed Jan 15, 2020
commit 962d0c3eb983efa22719484b41666c67876e9d31
6 changes: 3 additions & 3 deletions modules/migrations/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (g *GithubDownloaderV3) GetIssues(page, perPage int) ([]*base.Issue, bool,

// get reactions
var reactions []*base.Reaction
for i := 0; ; i++ {
for i := 1; ; i++ {
g.sleep()
res, resp, err := g.client.Reactions.ListIssueReactions(g.ctx, g.repoOwner, g.repoName, issue.GetNumber(), &github.ListOptions{
Page: i,
Expand Down Expand Up @@ -430,7 +430,7 @@ func (g *GithubDownloaderV3) GetComments(issueNumber int64) ([]*base.Comment, er

// get reactions
var reactions []*base.Reaction
for i := 0; ; i++ {
for i := 1; ; i++ {
g.sleep()
res, resp, err := g.client.Reactions.ListIssueCommentReactions(g.ctx, g.repoOwner, g.repoName, comment.GetID(), &github.ListOptions{
Page: i,
Expand Down Expand Up @@ -544,7 +544,7 @@ func (g *GithubDownloaderV3) GetPullRequests(page, perPage int) ([]*base.PullReq

// get reactions
var reactions []*base.Reaction
for i := 0; ; i++ {
for i := 1; ; i++ {
g.sleep()
res, resp, err := g.client.Reactions.ListIssueReactions(g.ctx, g.repoOwner, g.repoName, pr.GetNumber(), &github.ListOptions{
Page: i,
Expand Down
89 changes: 56 additions & 33 deletions modules/migrations/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,12 @@ func TestGitHubDownloadRepo(t *testing.T) {
Description: "Good for newcomers",
},
},
Reactions: &base.Reactions{
TotalCount: 1,
PlusOne: 1,
MinusOne: 0,
Laugh: 0,
Confused: 0,
Heart: 0,
Hooray: 0,
Reactions: []*base.Reaction{
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "+1",
},
},
Closed: &closed1,
},
Expand All @@ -198,14 +196,37 @@ func TestGitHubDownloadRepo(t *testing.T) {
Description: "This issue or pull request already exists",
},
},
Reactions: &base.Reactions{
TotalCount: 6,
PlusOne: 1,
MinusOne: 1,
Laugh: 1,
Confused: 1,
Heart: 1,
Hooray: 1,
Reactions: []*base.Reaction{
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "heart",
},
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "laugh",
},
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "confused",
},
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "hooray",
},
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "+1",
},
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "+1",
},
},
Closed: &closed2,
},
Expand All @@ -223,14 +244,12 @@ func TestGitHubDownloadRepo(t *testing.T) {
Created: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 21, 0, 13, 0, time.UTC),
Content: "This is a comment",
Reactions: &base.Reactions{
TotalCount: 1,
PlusOne: 1,
MinusOne: 0,
Laugh: 0,
Confused: 0,
Heart: 0,
Hooray: 0,
Reactions: []*base.Reaction{
{
UserID: 1669571,
UserName: "mrsdizzie",
Content: "+1",
},
},
},
{
Expand All @@ -240,15 +259,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
Created: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
Updated: time.Date(2019, 11, 12, 22, 7, 14, 0, time.UTC),
Content: "A second comment",
Reactions: &base.Reactions{
TotalCount: 0,
PlusOne: 0,
MinusOne: 0,
Laugh: 0,
Confused: 0,
Heart: 0,
Hooray: 0,
},
Reactions: nil,
},
}, comments[:2])

Expand Down Expand Up @@ -331,6 +342,18 @@ func TestGitHubDownloadRepo(t *testing.T) {
},
Merged: false,
MergeCommitSHA: "565d1208f5fffdc1c5ae1a2436491eb9a5e4ebae",
Reactions: []*base.Reaction{
{
UserID: 81045,
UserName: "lunny",
Content: "heart",
},
{
UserID: 81045,
UserName: "lunny",
Content: "+1",
},
},
},
}, prs)
}