mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(milestone): address milestones by title or ID everywhere
milestone view v2.0 failed with "invalid resource number" although its usage promised <id-or-name>, and issue create --milestone v1.0 failed with a strconv error. Every milestone argument (view, edit, delete, close, reopen, milestone issue add|remove|list) and issue create|edit -m/--milestone now accept a title or an ID: a number is an ID first, then a title; --by-name matches numeric titles only. --milestone-name stays as a hidden name of --milestone, and issue edit gains --remove-milestone (as does --milestone 0). Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
12 files changed
+220
-147
No files matched your search
@@ -17,9 +17,13 @@ import (
|
||||
func TestBulkMilestoneStateContinuesAfterFailureAndKeepsJSONClean(t *testing.T) {
|
||||
mutations := []string{}
|
||||
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path == "/api/v1/repos/alice/project/milestones" {
|
||||
writeMilestones(w, r, `[{"id":9,"title":"v9"},{"id":10,"title":"v10"},{"id":11,"title":"v11"}]`)
|
||||
return
|
||||
}
|
||||
id := strings.TrimPrefix(r.URL.Path, "/api/v1/repos/alice/project/milestones/")
|
||||
if r.Method == http.MethodGet {
|
||||
_, _ = fmt.Fprintf(w, `{"id":%s,"title":"Milestone %s"}`, id, id)
|
||||
_, _ = fmt.Fprintf(w, `{"id":%s,"title":"v%s"}`, id, id)
|
||||
return
|
||||
}
|
||||
mutations = append(mutations, id)
|
||||
@@ -32,7 +36,7 @@ func TestBulkMilestoneStateContinuesAfterFailureAndKeepsJSONClean(t *testing.T)
|
||||
defer server.Close()
|
||||
deps, out, diagnostics := serverDeps(t, server.URL)
|
||||
err := Execute(context.Background(), deps, []string{"milestone", "close", "9", "10", "11", "-R", "alice/project", "--json=id,state"})
|
||||
require.ErrorContains(t, err, "milestone 10")
|
||||
require.ErrorContains(t, err, "milestone v10")
|
||||
require.Equal(t, clierr.Failure, clierr.ExitCode(err))
|
||||
require.Equal(t, []string{"9", "10", "11"}, mutations)
|
||||
require.JSONEq(t, `[{"id":9,"state":"closed"},{"id":11,"state":"closed"}]`, out.String())
|
||||
@@ -40,7 +44,7 @@ func TestBulkMilestoneStateContinuesAfterFailureAndKeepsJSONClean(t *testing.T)
|
||||
mutations = nil
|
||||
out.Reset()
|
||||
err = Execute(context.Background(), deps, []string{"milestone", "close", "9", "bad", "-R", "alice/project"})
|
||||
require.Equal(t, clierr.Usage, clierr.ExitCode(err))
|
||||
require.ErrorContains(t, err, `milestone "bad" not found in alice/project`)
|
||||
require.Empty(t, mutations)
|
||||
require.Empty(t, out.String())
|
||||
}
|
||||
Reference in new issue
Block a user