feat(pulls): add tea pr stack list|show|push|restack|merge

Adds a CLI client for the Gitea EE pull request stack API
(GET/POST /repos/{owner}/{repo}/stacks[/{id}[/entries|/restack|/merge]]):

- modules/stack holds the Stack/Entry/MergeResult types shared between
  the API client and its output formatting, avoiding an import cycle
  between modules/task and modules/print.
- modules/task/pull_stack.go implements the HTTP calls on top of
  modules/api.Client, which gains a context-aware DoContext method.
- modules/print/pull_stack.go formats stack listings (table/json/...)
  and a single stack's ordered entries.
- cmd/pulls/stack adds the list, show, push, restack and merge
  subcommands, wired in as 'tea pr stack' via cmd/pulls.go, following
  the repo/login flag routing used by the rest of the pulls commands.

Assisted-by: Codet:GPT-5-Codex
This commit is contained in:
Lunny Xiao
2026-09-24 23:24:26 -07:00
parent 9c12138d62
commit ba167a7352
18 changed files with 1131 additions and 1 deletions
+7 -1
View File
@@ -4,6 +4,7 @@
package api
import (
"context"
"crypto/tls"
"fmt"
"io"
@@ -43,13 +44,18 @@ func NewClient(login *config.Login) *Client {
// Do executes an HTTP request with authentication headers
func (c *Client) Do(method, endpoint string, body io.Reader, headers map[string]string) (*http.Response, error) {
return c.DoContext(context.Background(), method, endpoint, body, headers)
}
// DoContext executes an HTTP request with authentication headers, bound to ctx
func (c *Client) DoContext(ctx context.Context, method, endpoint string, body io.Reader, headers map[string]string) (*http.Response, error) {
// Build the full URL
reqURL, err := c.buildURL(endpoint)
if err != nil {
return nil, err
}
req, err := http.NewRequest(method, reqURL, body)
req, err := http.NewRequestWithContext(ctx, method, reqURL, body)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}