mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
feat(issue): gh-style issue list, view, create, edit, close and reopen
issue list renders through the shared table: a context line, ID TITLE LABELS [STATE] [KIND] AUTHOR UPDATED with relative times on a terminal, the ID colored by state and linked, and a stable tab-separated column set when piped; empty results say so on stderr. It gains -s -L -l -a -A -m -S -w, @me, comma-separated label and milestone filters, and --web. issue view, edit, close and reopen accept #N, OWNER/REPO#N and issue URLs. Mutations report "✓ Created/Edited/Closed issue alice/x#5 (title)" on a terminal; issue create prints the new issue's URL on stdout (also as issue new), and close and reopen skip issues already in that state with a ! line and take -c/--comment. issue create and edit gain the gh short flags and singular --add-label, --remove-label, --add-assignee and --remove-assignee (the plural names still work), and create gains --web. The interactive create form asks for the title and body, then "What's next?" (submit, add metadata or cancel), without a confirmation after it; the edit form names the issue it edits. Every issue command has help text with examples and completes its flags and issue numbers. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
18 files changed
+789
-376
No files matched your search
@@ -64,3 +64,53 @@ func TestIssueEditMergesAssigneesWithOneRead(t *testing.T) {
|
||||
require.Equal(t, 1, reads)
|
||||
require.Equal(t, []any{"alice", "carol"}, patched)
|
||||
}
|
||||
|
||||
func TestIssueMutationsReportDoneLines(t *testing.T) {
|
||||
var changed []string
|
||||
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.Method + " " + r.URL.Path {
|
||||
case "GET /api/v1/repos/alice/project/issues/5":
|
||||
_, _ = w.Write([]byte(`{"number":5,"title":"Open one","state":"open"}`))
|
||||
case "GET /api/v1/repos/alice/project/issues/6":
|
||||
_, _ = w.Write([]byte(`{"number":6,"title":"Closed one","state":"closed"}`))
|
||||
case "GET /api/v1/repos/alice/project/issues/14":
|
||||
_, _ = w.Write([]byte(`{"number":14,"title":"Merged one","state":"closed","pull_request":{"merged":true}}`))
|
||||
case "POST /api/v1/repos/alice/project/issues":
|
||||
changed = append(changed, r.Method+" "+r.URL.Path)
|
||||
_, _ = w.Write([]byte(`{"number":9,"title":"New","state":"open","html_url":"https://example.org/alice/project/issues/9"}`))
|
||||
case "POST /api/v1/repos/alice/project/issues/5/comments":
|
||||
changed = append(changed, r.Method+" "+r.URL.Path+" "+payloadField(t, r, "body"))
|
||||
_, _ = w.Write([]byte(`{"id":1}`))
|
||||
default:
|
||||
changed = append(changed, r.Method+" "+r.URL.Path)
|
||||
_, _ = w.Write([]byte(`{"number":5,"title":"Open one","state":"closed"}`))
|
||||
}
|
||||
}))
|
||||
defer server.Close()
|
||||
deps, out, diagnostics := serverDeps(t, server.URL)
|
||||
deps.Getenv = serverEnv(server.URL, map[string]string{"NO_COLOR": "1"})
|
||||
run := func(tty bool, args ...string) {
|
||||
t.Helper()
|
||||
out.Reset()
|
||||
diagnostics.Reset()
|
||||
deps.Streams.OutTTY = tty
|
||||
require.NoError(t, Execute(context.Background(), deps, append(args, "-R", "alice/project", "--no-input")))
|
||||
}
|
||||
run(true, "issue", "close", "5", "#6", "14", "-c", "Fixed in #7")
|
||||
require.Empty(t, out.String())
|
||||
require.Equal(t, "✓ Closed issue alice/project#5 (Open one)\n"+
|
||||
"! Issue alice/project#6 (Closed one) is already closed\n"+
|
||||
"! Pull request alice/project#14 (Merged one) is already merged\n", diagnostics.String())
|
||||
require.Equal(t, []string{"POST /api/v1/repos/alice/project/issues/5/comments Fixed in #7", "PATCH /api/v1/repos/alice/project/issues/5"}, changed)
|
||||
run(false, "issue", "reopen", "6")
|
||||
require.Empty(t, out.String())
|
||||
require.Empty(t, diagnostics.String())
|
||||
run(true, "issue", "create", "--title", "New")
|
||||
require.Equal(t, "https://example.org/alice/project/issues/9\n", out.String())
|
||||
require.Equal(t, "✓ Created issue alice/project#9 (New)\n", diagnostics.String())
|
||||
run(false, "issue", "new", "--title", "New")
|
||||
require.Equal(t, "https://example.org/alice/project/issues/9\n", out.String())
|
||||
require.Empty(t, diagnostics.String())
|
||||
run(true, "issue", "edit", "5", "--title", "Open one")
|
||||
require.Equal(t, "✓ Edited issue alice/project#5 (Open one)\n", diagnostics.String())
|
||||
}
|
||||
Reference in new issue
Block a user