-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[API] Milestone endpoints accept names too #12649
[API] Milestone endpoints accept names too #12649
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12649 +/- ##
==========================================
+ Coverage 43.15% 43.17% +0.01%
==========================================
Files 654 654
Lines 72205 72218 +13
==========================================
+ Hits 31159 31179 +20
+ Misses 35998 35986 -12
- Partials 5048 5053 +5
Continue to review full report at Codecov.
|
as per @lafriks lable |
@zeripath renamed |
I really wonder if this is necessary to implement; the API does not need to act via name for user convenience because it's not designed for that, and CLI utility can implement a very simple logic to fetch ID and names mappings from API. This would also allow CLI to perform some interesting resolve mechanism, such as:
What do you say @6543, wouldn't this be better abstracted from main Gitea code? |
@CirnoT "resolving" the milestone by name was called "low efficient" so I go this way around |
It might be easiest, but are we really going to support this for every single API that takes ID? |
@CirnoT otherwise we have to do this on client side: // ResolveMilestoneIDByName is a fallback method to find milestone id by name
func (c *Client) ResolveMilestoneIDByName(owner, repo, name string) (int64, error) {
i := 0
for {
i++
miles, err := c.ListRepoMilestones(owner, repo, ListMilestoneOption{
ListOptions: ListOptions{
Page: i,
},
State: "all",
Name: name,
})
if err != nil {
return 0, err
}
if len(miles) == 0 {
return 0, fmt.Errorf("milestone '%s' do not exist", name)
}
for _, m := range miles {
if strings.ToLower(strings.TrimSpace(m.Title)) == strings.ToLower(strings.TrimSpace(name)) {
return m.ID, nil
}
}
}
} |
@CirnoT only if it realy make sence (to lower api requests) I would say |
🚀 |
similar to #12366 but for milestones
is very usefull for https://gitea.com/gitea/go-sdk/pulls/388 ... and so on