mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: address verified review findings (issues-1)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
16 files changed
+225
-27
No files matched your search
@@ -383,7 +383,8 @@ func (a *application) completeLabels() cobra.CompletionFunc {
|
||||
}))
|
||||
}
|
||||
|
||||
// completeMilestones completes the titles of open milestones.
|
||||
// completeMilestones completes the titles of open milestones. A numeric title would be read as
|
||||
// another milestone's ID, so such a milestone is completed by its own ID instead.
|
||||
func (a *application) completeMilestones() cobra.CompletionFunc {
|
||||
return a.completeMilestonesIn("open")
|
||||
}
|
||||
@@ -392,7 +393,13 @@ func (a *application) completeMilestones() cobra.CompletionFunc {
|
||||
func (a *application) completeMilestonesIn(state string) cobra.CompletionFunc {
|
||||
return a.apiCompletion(true, func(ctx context.Context, t target, _ string) ([]cobra.Completion, error) {
|
||||
items, err := services.Milestones{Client: t.client, Repository: t.Repo}.List(ctx, state, completionLimit, 1)
|
||||
return describe(items, func(item services.Milestone) (string, string) { return item.Title, item.Description }), err
|
||||
return describe(items, func(item services.Milestone) (string, string) {
|
||||
// A title that reads as a number would be taken as an ID, so offer the ID instead.
|
||||
if _, parse := strconv.ParseInt(strings.TrimSpace(item.Title), 10, 64); parse == nil {
|
||||
return strconv.FormatInt(item.ID, 10), strings.TrimSpace(item.Title + " " + item.Description)
|
||||
}
|
||||
return item.Title, item.Description
|
||||
}), err
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user