|
|
|
@ -55,6 +55,23 @@ func (f *GitlabDownloaderFactory) GitServiceType() structs.GitServiceType { |
|
|
|
|
return structs.GitlabService |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type gitlabIIDResolver struct { |
|
|
|
|
maxIssueIID int64 |
|
|
|
|
frozen bool |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r *gitlabIIDResolver) recordIssueIID(issueIID int) { |
|
|
|
|
if r.frozen { |
|
|
|
|
panic("cannot record issue IID after pull request IID generation has started") |
|
|
|
|
} |
|
|
|
|
r.maxIssueIID = max(r.maxIssueIID, int64(issueIID)) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r *gitlabIIDResolver) generatePullRequestNumber(mrIID int) int64 { |
|
|
|
|
r.frozen = true |
|
|
|
|
return r.maxIssueIID + int64(mrIID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GitlabDownloader implements a Downloader interface to get repository information
|
|
|
|
|
// from gitlab via go-gitlab
|
|
|
|
|
// - issueCount is incremented in GetIssues() to ensure PR and Issue numbers do not overlap,
|
|
|
|
@ -66,7 +83,7 @@ type GitlabDownloader struct { |
|
|
|
|
baseURL string |
|
|
|
|
repoID int |
|
|
|
|
repoName string |
|
|
|
|
issueCount int64 |
|
|
|
|
iidResolver gitlabIIDResolver |
|
|
|
|
maxPerPage int |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -450,8 +467,8 @@ func (g *GitlabDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er |
|
|
|
|
Context: gitlabIssueContext{IsMergeRequest: false}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// increment issueCount, to be used in GetPullRequests()
|
|
|
|
|
g.issueCount++ |
|
|
|
|
// record the issue IID, to be used in GetPullRequests()
|
|
|
|
|
g.iidResolver.recordIssueIID(issue.IID) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return allIssues, len(issues) < perPage, nil |
|
|
|
@ -594,8 +611,8 @@ func (g *GitlabDownloader) GetPullRequests(page, perPage int) ([]*base.PullReque |
|
|
|
|
awardPage++ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Add the PR ID to the Issue Count because PR and Issues share ID space in Gitea
|
|
|
|
|
newPRNumber := g.issueCount + int64(pr.IID) |
|
|
|
|
// Generate new PR Numbers by the known Issue Numbers, because they share the same number space in Gitea, but they are independent in Gitlab
|
|
|
|
|
newPRNumber := g.iidResolver.generatePullRequestNumber(pr.IID) |
|
|
|
|
|
|
|
|
|
allPRs = append(allPRs, &base.PullRequest{ |
|
|
|
|
Title: pr.Title, |
|
|
|
|