Skip to content

feat: Add mark_pr_ready_for_review tool #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

efouts
Copy link

@efouts efouts commented May 22, 2025

This commit introduces a new tool, mark_pr_ready_for_review, which allows changing a GitHub pull request from a draft state to ready for review.

This tool utilizes the GitHub GraphQL API's markPullRequestReadyForReview mutation, as the REST API does not support this specific state transition for existing draft PRs.

The implementation includes the tool logic, its registration in the pull_requests toolset, and comprehensive tests.

@Copilot Copilot AI review requested due to automatic review settings May 22, 2025 06:25
@efouts efouts requested a review from a team as a code owner May 22, 2025 06:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Introduce a new tool to transition draft GitHub pull requests to ready-for-review state via GraphQL, including command registration, implementation, and tests.

  • Register the mark_pr_ready_for_review tool in the server toolset.
  • Implement the GraphQL query and mutation for marking a PR as ready for review.
  • Add comprehensive unit tests for success and failure scenarios.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/github/tools.go Register new mark_pr_ready_for_review tool.
pkg/github/pullrequests.go Implement GraphQL logic for marking draft PRs as ready for review.
pkg/github/pullrequests_test.go Add unit tests covering various success/failure cases for the new tool.
Comments suppressed due to low confidence (2)

pkg/github/pullrequests_test.go:2295

  • Add a test case for failure to obtain the GraphQL client (e.g., have getGQLClient return an error) to verify the handler surfaces this as a tool error instead of returning a raw error.
func TestMarkPullRequestReadyForReview(t *testing.T) {

pkg/github/pullrequests.go:1638

  • Add a test to cover parameter decoding failures (e.g., missing or wrong-type owner/repo/pullNumber) so you can confirm those errors are returned as tool errors.
if err := mapstructure.Decode(request.Params.Arguments, &params); err != nil {

@efouts efouts requested a review from Copilot May 22, 2025 23:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new CLI tool (mark_pr_ready_for_review) that transitions a draft GitHub pull request to ready-for-review via the GraphQL API.

  • Registers the new tool in the existing toolset.
  • Implements the GraphQL query/mutation logic in pullrequests.go.
  • Provides comprehensive unit tests for success and failure scenarios.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/tools.go Registers MarkPullRequestReadyForReview in toolset
pkg/github/pullrequests.go Implements the new GraphQL-based ready-for-review tool
pkg/github/pullrequests_test.go Adds tests covering all new tool behaviors
Comments suppressed due to low confidence (1)

pkg/github/pullrequests.go:1664

  • The local variables owner, repo, and pullNumber are parsed above, but the code mistakenly references an undefined params struct here. Update the variables map to use the parsed locals, e.g.: "owner": githubv4.String(owner), "repo": githubv4.String(repo), and "prNum": githubv4.Int(pullNumber).
"owner": githubv4.String(params.Owner),

@efouts efouts force-pushed the feat/mark-pr-ready-for-review branch from 8731a4c to 43d6692 Compare May 23, 2025 00:41
@efouts efouts requested a review from Copilot May 23, 2025 00:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new tool, mark_pr_ready_for_review, to change a draft pull request into a ready for review state by using the GitHub GraphQL API.

  • Registers the new tool in the toolset.
  • Implements the GraphQL mutation to mark PRs as ready.
  • Adds comprehensive tests to validate the tool's behavior.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/tools.go Registers the new MarkPullRequestReadyForReview tool
pkg/github/pullrequests_test.go Adds tests covering success and various failure scenarios for the new tool
pkg/github/pullrequests.go Implements the GraphQL logic for marking a pull request ready for review

@efouts efouts force-pushed the feat/mark-pr-ready-for-review branch from 43d6692 to 2b5ec67 Compare May 23, 2025 05:07
@SamMorrowDrums
Copy link
Collaborator

Thanks very much for the contribution @efouts I was thinking about this PR and wondering if it might make sense to convert it to set_pr_state and provide an enum for setting the PR to draft, as well as marking as ready tor review. WDYT?

@efouts
Copy link
Author

efouts commented May 23, 2025

Thanks very much for the contribution @efouts I was thinking about this PR and wondering if it might make sense to convert it to set_pr_state and provide an enum for setting the PR to draft, as well as marking as ready tor review. WDYT?

@SamMorrowDrums happy to do that or add another tool mirroring the convertpullrequesttodraft mutation. which is most in line with the project?

(edit) I went ahead and updated to be set_pr_state with the guess that is the preference.

efouts added 3 commits May 23, 2025 12:38
This commit introduces a new tool that allows changing a GitHub pull
request from draft state to ready for review.

The implementation uses GitHub's GraphQL API with the
'markPullRequestReadyForReview' mutation, as the REST API doesn't
support this state transition for existing draft PRs.

Also fixes the GraphQL query by correcting 'Draft' to 'IsDraft' field
name, ensuring proper detection of a PR's draft status.

The changes include:
- New tool implementation in the pull_requests toolset
- Comprehensive tests
- GraphQL query field correction
Based on code review feedback, made the following improvements:
- Rename 'variables' to 'vars' for consistency with other GraphQL functions
- Improve comment precision for GraphQL schema requirements

These changes enhance code consistency and documentation clarity while
maintaining full functionality. All tests, linting, and build checks pass.
- Replace mark_pr_ready_for_review with set_pr_status tool
- Add bidirectional PR status changes (draft ↔ ready_for_review)
- Use enum parameter for status: "draft", "ready_for_review"
- Implement GraphQL mutations for both directions
- Add comprehensive test suite with 8 test scenarios
- Remove deprecated MarkPullRequestReadyForReview function

Addresses user feedback to provide enum-based PR status management
with support for setting PRs to both draft and ready-for-review states.
@efouts efouts force-pushed the feat/mark-pr-ready-for-review branch from 2b5ec67 to 650aac6 Compare May 23, 2025 16:38
@efouts efouts requested a review from Copilot May 23, 2025 16:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new tool, mark_pr_ready_for_review, to allow changing a GitHub pull request's state from draft to ready-for-review (and vice versa), using the GitHub GraphQL API.

  • Added a new tool registration (SetPRStatus) in pkg/github/tools.go.
  • Implemented the tool logic in pkg/github/pullrequests.go with corresponding tests in pkg/github/pullrequests_test.go.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/tools.go Registers the new SetPRStatus tool in the toolset.
pkg/github/pullrequests_test.go Adds comprehensive tests for both state transition paths.
pkg/github/pullrequests.go Implements the GraphQL logic for setting the pull request status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants