Skip to content

Commit adfe13f

Browse files
Add migrated pulls to pull request task queue (#13331) (#13334)
* Add migrated pulls to pull request task queue Fix #13321 Signed-off-by: Andrew Thornton <[email protected]> * Improve error reports Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 47cb9b3 commit adfe13f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

modules/migrations/gitea_downloader.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (f *GiteaDownloaderFactory) New(ctx context.Context, opts base.MigrateOptio
4747

4848
path := strings.Split(repoNameSpace, "/")
4949
if len(path) < 2 {
50-
return nil, fmt.Errorf("invalid path")
50+
return nil, fmt.Errorf("invalid path: %s", repoNameSpace)
5151
}
5252

5353
repoPath := strings.Join(path[len(path)-2:], "/")
@@ -87,7 +87,7 @@ func NewGiteaDownloader(ctx context.Context, baseURL, repoPath, username, passwo
8787
gitea_sdk.SetContext(ctx),
8888
)
8989
if err != nil {
90-
log.Error(fmt.Sprintf("NewGiteaDownloader: %s", err.Error()))
90+
log.Error(fmt.Sprintf("Failed to create NewGiteaDownloader for: %s. Error: %v", baseURL, err))
9191
return nil, err
9292
}
9393

@@ -395,7 +395,7 @@ func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, err
395395

396396
reactions, err := g.getIssueReactions(issue.Index)
397397
if err != nil {
398-
return nil, false, fmt.Errorf("error while loading reactions: %v", err)
398+
return nil, false, fmt.Errorf("error while loading reactions for issue #%d. Error: %v", issue.Index, err)
399399
}
400400

401401
var assignees []string
@@ -446,13 +446,13 @@ func (g *GiteaDownloader) GetComments(index int64) ([]*base.Comment, error) {
446446
// Page: i,
447447
}})
448448
if err != nil {
449-
return nil, fmt.Errorf("error while listing comments: %v", err)
449+
return nil, fmt.Errorf("error while listing comments for issue #%d. Error: %v", index, err)
450450
}
451451

452452
for _, comment := range comments {
453453
reactions, err := g.getCommentReactions(comment.ID)
454454
if err != nil {
455-
return nil, fmt.Errorf("error while listing comment creactions: %v", err)
455+
return nil, fmt.Errorf("error while listing reactions for comment %d in issue #%d. Error: %v", comment.ID, index, err)
456456
}
457457

458458
allComments = append(allComments, &base.Comment{
@@ -490,7 +490,7 @@ func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullReques
490490
State: gitea_sdk.StateAll,
491491
})
492492
if err != nil {
493-
return nil, false, fmt.Errorf("error while listing repos: %v", err)
493+
return nil, false, fmt.Errorf("error while listing pull requests (page: %d, pagesize: %d). Error: %v", page, perPage, err)
494494
}
495495
for _, pr := range prs {
496496
var milestone string
@@ -521,7 +521,7 @@ func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullReques
521521
if headSHA == "" {
522522
headCommit, _, err := g.client.GetSingleCommit(g.repoOwner, g.repoName, url.PathEscape(pr.Head.Ref))
523523
if err != nil {
524-
return nil, false, fmt.Errorf("error while resolving git ref: %v", err)
524+
return nil, false, fmt.Errorf("error while resolving head git ref: %s for pull #%d. Error: %v", pr.Head.Ref, pr.Index, err)
525525
}
526526
headSHA = headCommit.SHA
527527
}
@@ -534,7 +534,7 @@ func (g *GiteaDownloader) GetPullRequests(page, perPage int) ([]*base.PullReques
534534

535535
reactions, err := g.getIssueReactions(pr.Index)
536536
if err != nil {
537-
return nil, false, fmt.Errorf("error while loading reactions: %v", err)
537+
return nil, false, fmt.Errorf("error while loading reactions for pull #%d. Error: %v", pr.Index, err)
538538
}
539539

540540
var assignees []string

modules/migrations/gitea_uploader.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"code.gitea.io/gitea/modules/storage"
2929
"code.gitea.io/gitea/modules/structs"
3030
"code.gitea.io/gitea/modules/timeutil"
31+
"code.gitea.io/gitea/services/pull"
3132

3233
gouuid "github.com/google/uuid"
3334
)
@@ -524,6 +525,7 @@ func (g *GiteaLocalUploader) CreatePullRequests(prs ...*base.PullRequest) error
524525
}
525526
for _, pr := range gprs {
526527
g.issues.Store(pr.Issue.Index, pr.Issue.ID)
528+
pull.AddToTaskQueue(pr)
527529
}
528530
return nil
529531
}

0 commit comments

Comments
 (0)