Skip to content

Commit 0a77a76

Browse files
committed
Skip closed merge requests where the change is already in trunk branch
1 parent 993442e commit 0a77a76

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

project.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ func (p *project) migrateMergeRequests(ctx context.Context) {
285285
} else {
286286
successCount++
287287
}
288-
// call out to migrateMergeRequest and increment counters
289288
}
290289

291290
skippedCount := totalCount - successCount - failureCount
@@ -572,6 +571,10 @@ func (p *project) migrateMergeRequest(ctx context.Context, mergeRequest *gitlab.
572571
Draft: &mergeRequest.Draft,
573572
}
574573
if pullRequest, _, err = gh.PullRequests.Create(ctx, p.githubPath[0], p.githubPath[1], &newPullRequest); err != nil {
574+
if mergeRequest.State == "closed" && strings.Contains(err.Error(), "No commits between") {
575+
logger.Debug("skipping closed merge request as the change is already present in trunk branch", "owner", p.githubPath[0], "repo", p.githubPath[1], "merge_request_id", mergeRequest.IID)
576+
return nil
577+
}
575578
return fmt.Errorf("creating pull request: %v", err)
576579
}
577580

0 commit comments

Comments
 (0)