You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "KatalKavya96 (via GitHub)" <gi...@apache.org> on 2026/10/21 04:10:15 UTC
[PR] feat(bitbucket): add Data Center review state writes [magpie]
KatalKavya96 opened a new pull request, #1746:
URL: https://github.com/apache/magpie/pull/1746
## Summary
- Add Bitbucket Data Center support for pull-request approval and change-request state writes.
- Reuse the existing backend-neutral commands:
- `pr approve`
- `pr unapprove`
- `pr request-changes`
- `pr remove-request-changes`
- Use the Data Center participant-status API for the authenticated reviewer.
- Add direct API and CLI coverage for all four operations.
- Update Bitbucket capability documentation to reflect Cloud + Data Center support.
## Type of change
- [ ] Skill change (`.claude/skills/<name>/`)
- [x] Tool / bridge contract (`tools/<system>/*.md`)
- [x] Python package (`tools/*/` with `pyproject.toml`)
- [ ] Groovy reference impl
- [ ] Cross-cutting
- [x] Documentation
- [ ] Project template
- [ ] CI / dev loop
- [ ] Other
## Implementation
Bitbucket Data Center review state is updated through the pull-request participant resource for the authenticated user.
The command mappings are:
- `pr approve` → `APPROVED`
- `pr unapprove` → `UNAPPROVED`
- `pr request-changes` → `NEEDS_WORK`
- `pr remove-request-changes` → `UNAPPROVED`
The bridge first resolves the authenticated Data Center user's slug, then updates that user's participant state on the target pull request.
This avoids the deprecated approval-specific endpoints and keeps the existing normalized approval/change-request output contracts unchanged across Cloud and Data Center.
## Test plan
- [x] Ruff checks pass
- [x] Ruff formatting passes
- [x] Mypy passes
- [x] Focused Data Center review-state tests pass
- [x] Full `tools/bitbucket/tests/test_bitbucket.py` suite passes
- [x] CLI coverage added for all four Data Center commands
- [x] `git diff --check` passes
- [x] Repository hooks pass
## Scope
This PR adds standalone Data Center review-state mutations only.
The combined:
`pr review <id> --verdict {comment,approve,request-changes} --body-file <path>`
path remains Cloud-only because Data Center review-body + verdict semantics are a separate follow-up.
Data Center decline/reject and merge writes also remain separate follow-ups.
Refs #606
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bitbucket): add Data Center review state writes [magpie]
Posted by "KatalKavya96 (via GitHub)" <gi...@apache.org>.
KatalKavya96 commented on PR #1746:
URL: https://github.com/apache/magpie/pull/1746#issuecomment-6307830943
Hi @potiuk,
This is the next focused #606 Data Center parity follow-up.
It enables the existing standalone review-state commands on Data Center through the participant-status API:
- approve → `APPROVED`
- unapprove → `UNAPPROVED`
- request-changes → `NEEDS_WORK`
- remove-request-changes → `UNAPPROVED`
The implementation keeps the existing backend-neutral CLI and normalizers, adds API + CLI coverage for all four operations, and avoids the deprecated approval-specific endpoints.
The combined `pr review --body-file` path remains Cloud-only and is intentionally left for a separate follow-up.
Refs #606
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(bitbucket): add Data Center review state writes [magpie]
Posted by "Kaap10 (via GitHub)" <gi...@apache.org>.
Kaap10 commented on code in PR #1746:
URL: https://github.com/apache/magpie/pull/1746#discussion_r4340482622
##########
tools/bitbucket/src/magpie_bitbucket/datacenter.py:
##########
@@ -357,47 +358,96 @@ def get_pull_request_status(config: BitbucketConfig, pull_request_id: str) -> di
return combined
+def _current_user_slug(config: BitbucketConfig) -> str:
+ """Return the authenticated Bitbucket Data Center user's URL-safe slug."""
+ user = get_json(f"{_api_base(config)}/users", config)
Review Comment:
In Bitbucket Data Center REST API v1.0, `GET /rest/api/1.0/users` is a paged user-directory search returning `{"values": [...], "size": ...}` rather than a single user object. Because there is no top-level `slug` field, `user.get("slug")` returns `None` on live instances and raises `BitbucketError`. Consider extracting the `X-AUSERNAME` response header or reading `config.username`.
##########
tools/bitbucket/tests/test_bitbucket.py:
##########
@@ -3033,24 +3033,80 @@ def test_cloud_unapprove_pull_request_deletes_without_body(
assert result == {"pull_request_id": "7"}
-def test_datacenter_approve_pull_request_unsupported(
+@pytest.mark.parametrize(
+ ("operation", "expected_status"),
+ [
+ (datacenter.approve_pull_request, "APPROVED"),
+ (datacenter.unapprove_pull_request, "UNAPPROVED"),
+ ],
+)
+@patch("magpie_bitbucket.client.urllib.request.build_opener")
+def test_datacenter_pull_request_approval_status(
+ mock_build_opener: MagicMock,
+ operation: Any,
+ expected_status: str,
datacenter_env: None,
) -> None:
- with pytest.raises(
- BitbucketError,
- match="Data Center pull request approval writes are not supported",
- ):
- datacenter.approve_pull_request(load_config(), "9")
+ mock_opener(
Review Comment:
The mock simulates a flat `{"slug": "alice"}` object, which masks the paged `Page<User>` schema returned by `/rest/api/1.0/users`. Updating the test to mock the real endpoint schema will prevent regressions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org