1
0
Fork 0
mirror of https://gitea.com/gitea/tea.git synced 2026-04-25 08:37:48 +02:00
tea/modules/print
Bo-Yi Wu 9e0a6203ae feat(pulls): add ci status field to pull request list (#956)
## Summary

- Add `"ci"` as a new selectable field for `tea pr list --fields`, allowing users to see CI status across multiple PRs at a glance
- Fetch CI status via `GetCombinedStatus` API **only when the `ci` field is explicitly requested** via `--fields`, avoiding unnecessary API calls in default usage
- Improve CI status display in both detail and list views:
  - **Detail view** (`tea pr <index>`): show each CI check with symbol, context name, description, and clickable link to CI run
  - **List view** (`tea pr list --fields ci`): show symbol + context name per CI check (e.g., `✓ lint,  build,  test`)
  - **Machine-readable output**: return raw state string (e.g., `success`, `pending`)
- Replace pending CI symbol from `⭮` to `` for better readability
- Extract `formatCIStatus` helper and reuse it in `PullDetails` to reduce code duplication
- Add comprehensive tests for CI status formatting and PR list integration

## Detail View Example

```
- CI:
  - ✓ [**lint**](https://ci.example.com/lint): Lint passed
  -  [**build**](https://ci.example.com/build): Build is running
  -  [**test**](https://ci.example.com/test): 3 tests failed
```

## List View Example

```
INDEX  TITLE       STATE  CI
123    Fix bug     open   ✓ lint,  build,  test
```

## Usage

```bash
# Show CI status column in list
tea pr list --fields index,title,state,ci

# Default output is unchanged (no CI column, no extra API calls)
tea pr list
```

## Files Changed

- `cmd/pulls/list.go` — conditionally fetch CI status per PR when `ci` field is selected
- `modules/print/pull.go` — add `ci` field, `formatCIStatus` helper, improve detail/list CI display
- `modules/print/pull_test.go` — comprehensive tests for CI status formatting

## Test plan

- [x] `go build ./...` passes
- [x] `go test ./...` passes (11 new tests)
- [x] `tea pr list` — default output unchanged, no extra API calls
- [x] `tea pr list --fields index,title,state,ci` — CI column with context names
- [x] `tea pr <index>` — CI section shows each check with name, description, and link
- [x] `tea pr list --fields ci -o csv` — machine-readable output shows raw state strings

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: https://gitea.com/gitea/tea/pulls/956
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2026-04-10 17:29:15 +00:00
..
actions.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
actions_runs.go feat(workflows): add dispatch, view, enable and disable subcommands (#952) 2026-04-09 20:03:33 +00:00
actions_runs_test.go feat(workflows): add dispatch, view, enable and disable subcommands (#952) 2026-04-09 20:03:33 +00:00
actions_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
attachment.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
branch.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
branch_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
comment.go spdx (#581) 2023-09-08 01:40:02 +00:00
formatters.go Fix attachment size (#787) 2025-08-11 18:45:12 +00:00
issue.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
label.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
login.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
markdown.go Update to charm libraries v2 (#923) 2026-03-09 16:36:00 +00:00
milestone.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
notification.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
organization.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
pull.go feat(pulls): add ci status field to pull request list (#956) 2026-04-10 17:29:15 +00:00
pull_review_comment.go feat(pulls): add resolve, unresolve and review-comments subcommands (#948) 2026-04-08 03:36:09 +00:00
pull_test.go feat(pulls): add ci status field to pull request list (#956) 2026-04-10 17:29:15 +00:00
release.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
repo.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
repo_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
table.go refactor: code cleanup across codebase (#947) 2026-04-08 03:38:49 +00:00
table_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
times.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
user.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
webhook.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00
webhook_test.go replace log.Fatal/os.Exit with error returns (#941) 2026-03-27 03:36:44 +00:00