refactor: remove helpers the new output and prompts left unused

Drop writeDownload, terminal.Require, terminal.Confirm, terminal.Row,
terminal.Record and Pulls.FindOpenByHead, which no command calls anymore,
and point their tests at the code that replaced them.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 10:00:05 +02:00
1 parent eff6efe759
commit 50a604f169
8 files changed
+34 -118

No files matched your search

-26
View File
@@ -250,32 +250,6 @@ func (s Pulls) ListOpen(ctx context.Context) ([]Pull, error) {
})
}
// FindOpenByHead returns the unique open pull whose head branch matches name.
func (s Pulls) FindOpenByHead(ctx context.Context, head string) (Pull, error) {
head = strings.TrimSpace(head)
if head == "" {
return Pull{}, fmt.Errorf("head branch cannot be empty")
}
items, err := s.ListOpen(ctx)
if err != nil {
return Pull{}, err
}
matches := []Pull{}
for _, item := range items {
if item.Head == head {
matches = append(matches, item)
}
}
switch len(matches) {
case 0:
return Pull{}, fmt.Errorf("no open pull request uses head branch %q", head)
case 1:
return matches[0], nil
default:
return Pull{}, fmt.Errorf("multiple open pull requests use head branch %q; supply an explicit number", head)
}
}
// Create opens a pull request.
func (s Pulls) Create(ctx context.Context, opts PullOptions) (Pull, error) {
// TODO(sdk): CreatePullRequestOption lacks allow_maintainer_edit.
+4 -5
View File
@@ -57,7 +57,7 @@ func TestPullMilestoneClearUsesIssueEndpoint(t *testing.T) {
}
}
func TestFindOpenByHeadPagesPastSmallServerLimitsAndMatchesExactly(t *testing.T) {
func TestListOpenPagesPastSmallServerLimits(t *testing.T) {
client := newTestClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/api/v1/repos/alice/project/pulls", r.URL.Path)
switch r.URL.Query().Get("page") {
@@ -70,11 +70,10 @@ func TestFindOpenByHeadPagesPastSmallServerLimitsAndMatchesExactly(t *testing.T)
}
}))
service := Pulls{Client: client, Repository: "alice/project"}
item, err := service.FindOpenByHead(context.Background(), "feature")
items, err := service.ListOpen(context.Background())
require.NoError(t, err)
require.EqualValues(t, 2, item.Number)
_, err = service.FindOpenByHead(context.Background(), "FEATURE")
require.ErrorContains(t, err, "no open pull request")
require.Len(t, items, 2)
require.Equal(t, "feature", items[1].Head)
}
func TestListOpenRejectsEndlessPagination(t *testing.T) {