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

Use new OneDev /milestones endpoint #17782

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Changes from all commits
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
20 changes: 18 additions & 2 deletions services/migrations/onedev.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ func (d *OneDevDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er
State string `json:"state"`
Title string `json:"title"`
Description string `json:"description"`
MilestoneID int64 `json:"milestoneId"`
SubmitterID int64 `json:"submitterId"`
SubmitDate time.Time `json:"submitDate"`
}, 0, perPage)
Expand Down Expand Up @@ -325,6 +324,23 @@ func (d *OneDevDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er
}
}

milestones := make([]struct {
ID int64 `json:"id"`
Name string `json:"name"`
}, 0, 10)
err = d.callAPI(
fmt.Sprintf("/api/issues/%d/milestones", issue.ID),
nil,
&milestones,
)
if err != nil {
return nil, false, err
}
milestoneID := int64(0)
if len(milestones) > 0 {
milestoneID = milestones[0].ID
}

state := strings.ToLower(issue.State)
if state == "released" {
state = "closed"
Expand All @@ -336,7 +352,7 @@ func (d *OneDevDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, er
PosterName: poster.Name,
PosterEmail: poster.Email,
Content: issue.Description,
Milestone: d.milestoneMap[issue.MilestoneID],
Milestone: d.milestoneMap[milestoneID],
State: state,
Created: issue.SubmitDate,
Updated: issue.SubmitDate,
Expand Down