feat(pr): add +comments, +comment-edit, +comment-delete #385

Merged
wbtiger merged 1 commits from Taoyouce/gitlink-cli:feat/pr-comment-crud into master 2026-07-14 22:22:47 +08:00
Contributor

What

Completes the comment lifecycle for pull requests using the dedicated v1 pull-journals endpoints (Api::V1::Projects::Pulls::JournalsController). The CLI could only create PR comments; now:

gitlink-cli pr +comments --owner Gitlink --repo forgeplus -i 42
gitlink-cli pr +comment-edit --owner Gitlink --repo forgeplus -i 42 -c 484052 -b "Updated" -s resolved
gitlink-cli pr +comment-delete --owner Gitlink --repo forgeplus -i 42 -c 484052

Server contract detail worth noting

The update service hard-requires state with validates :state, inclusion: {in: %w(opened resolved disabled)} — a plain {"note": ...} PATCH fails with [-1] State不包含于列表中 (production-reproduced). So +comment-edit always sends state, defaulting to opened, and validates the enum client-side. --comment-id is integer-validated before any API call.

Validation

  • Production-verified full lifecycle on gitlink.org.cn: create → list (total_count reflects it) → edit (note updated in response) → delete status: 0; test comments cleaned up.
  • 3 unit tests (endpoint paths, note/state payload, enum + integer guards); go test ./..., go vet, gofmt all clean.
  • README examples and bilingual i18n keys included.
## What Completes the comment lifecycle for pull requests using the dedicated v1 pull-journals endpoints (`Api::V1::Projects::Pulls::JournalsController`). The CLI could only *create* PR comments; now: ```bash gitlink-cli pr +comments --owner Gitlink --repo forgeplus -i 42 gitlink-cli pr +comment-edit --owner Gitlink --repo forgeplus -i 42 -c 484052 -b "Updated" -s resolved gitlink-cli pr +comment-delete --owner Gitlink --repo forgeplus -i 42 -c 484052 ``` ### Server contract detail worth noting The update service hard-requires `state` with `validates :state, inclusion: {in: %w(opened resolved disabled)}` — a plain `{"note": ...}` PATCH fails with `[-1] State不包含于列表中` (production-reproduced). So `+comment-edit` always sends `state`, defaulting to `opened`, and validates the enum client-side. `--comment-id` is integer-validated before any API call. ## Validation - Production-verified full lifecycle on gitlink.org.cn: create → list (`total_count` reflects it) → edit (note updated in response) → delete `status: 0`; test comments cleaned up. - 3 unit tests (endpoint paths, `note`/`state` payload, enum + integer guards); `go test ./...`, `go vet`, `gofmt` all clean. - README examples and bilingual i18n keys included.
Taoyouce added 4 commits 2026-07-08 22:42:59 +08:00
cf42b86f65 feat(pr): add +comments, +comment-edit, +comment-delete
Completes the pull-journal comment lifecycle. The CLI could only
create PR comments (via the linked issue's journals); the dedicated
v1 pull journals endpoints also support list/update/destroy:

- pr +comments -i <num>: list a PR's journals
- pr +comment-edit -i <num> -c <journal-id> -b <text> [-s state]
- pr +comment-delete -i <num> -c <journal-id>

The server's UpdateService hard-requires state in
opened|resolved|disabled (omitting it fails with
'State不包含于列表中'), so +comment-edit always sends state,
defaulting to opened, with client-side validation of the enum.
--comment-id is integer-validated.

Production-verified full lifecycle on gitlink.org.cn:
create -> list -> edit (note updated) -> delete. 3 unit tests,
README examples, bilingual i18n keys.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
wbtiger merged commit 16a14b5571 into master 2026-07-14 22:22:46 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#385
No description provided.