Skip to content

🚀 [Feature]: Pull requests can now be listed, updated, and commented on#547

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-pull-request-management-commands
Draft

🚀 [Feature]: Pull requests can now be listed, updated, and commented on#547
Copilot wants to merge 4 commits intomainfrom
copilot/add-pull-request-management-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 9, 2026

Pull requests in a repository can now be listed, filtered, retrieved by number, updated, and commented on directly from PowerShell. This removes the need to shell out to the gh CLI for pull request automation scenarios such as closing superseded auto-update PRs.

New: List and retrieve pull requests

Get-GitHubPullRequest lists pull requests in a repository with optional filtering by state, head branch, base branch, sort order, and direction. A specific pull request can also be retrieved by number.

# List all open pull requests
Get-GitHubPullRequest -Owner 'PSModule' -Repository 'GitHub'

# Filter by state and head branch
Get-GitHubPullRequest -Owner 'PSModule' -Repository 'GoogleFonts' -State 'open' -Head 'PSModule:auto-update'

# Get a specific pull request by number
Get-GitHubPullRequest -Owner 'PSModule' -Repository 'GitHub' -Number 123

New: Update pull request state, title, and body

Update-GitHubPullRequest modifies a pull request's title, body, state (open/closed), base branch, or maintainer modification flag. Supports pipeline input from Get-GitHubPullRequest.

# Close a pull request
Update-GitHubPullRequest -Owner 'PSModule' -Repository 'GitHub' -Number 123 -State 'closed'

# Close all PRs from a specific branch via pipeline
Get-GitHubPullRequest -Owner 'PSModule' -Repository 'GoogleFonts' -Head 'PSModule:auto-update' |
    Update-GitHubPullRequest -State 'closed'

New: Comment on pull requests

New-GitHubPullRequestComment adds a comment to a pull request via the Issues API (since PRs are issues in the GitHub API). Supports pipeline input.

# Add a comment to a pull request
New-GitHubPullRequestComment -Owner 'PSModule' -Repository 'GitHub' -Number 123 -Body 'Superseded by newer PR'

# Comment on multiple PRs via pipeline
Get-GitHubPullRequest -Owner 'PSModule' -Repository 'GoogleFonts' -Head 'PSModule:auto-update' |
    New-GitHubPullRequestComment -Body 'This PR has been superseded.'

Technical Details

  • GitHubPullRequest class extends GitHubNode, mapping REST API fields to PascalCase properties. Includes null-safe handling for deleted fork repositories in head/base repo references.
  • Private functions in src/functions/private/PullRequests/: Get-GitHubPullRequestList (GET /repos/{owner}/{repo}/pulls), Get-GitHubPullRequestByNumber (GET /repos/{owner}/{repo}/pulls/{pull_number}), Update-GitHubPullRequestByNumber (PATCH /repos/{owner}/{repo}/pulls/{pull_number}), New-GitHubPullRequestCommentByNumber (POST /repos/{owner}/{repo}/issues/{issue_number}/comments).
  • Public functions follow the standard module pattern: filter keyword, Resolve-GitHubContext in begin block, switch on $PSCmdlet.ParameterSetName for routing.
  • Update-GitHubPullRequest and New-GitHubPullRequestComment use SupportsShouldProcess.
  • Tests validate listing PRs on an empty repository. Full CRUD tests require branch/commit setup and are noted as future work.
  • Endpoints not covered in this PR (future work): Create PR, Merge PR, List PR commits/files, Check merged status, Update PR branch.

Copilot AI and others added 3 commits February 9, 2026 09:50
- Add GitHubPullRequest class
- Add Get-GitHubPullRequest command (list and get by number)
- Add Update-GitHubPullRequest command (close, update title, body, etc.)
- Add New-GitHubPullRequestComment command (add comments to PRs)

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
- Use $Owner and $Repository instead of $OwnerName/$RepositoryName
- Add examples demonstrating PR management use cases
- Fix linter issues

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
- Add null checks for head/base repository properties
- Write errors to error stream when PR not found
- Address code review feedback

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copilot AI changed the title [WIP] Add pull request management commands for automation Add Pull Request management commands Feb 9, 2026
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title Add Pull Request management commands 🚀 [Feature]: Pull requests can now be listed, updated, and commented on Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Add Get, Update, and Comment commands for pull requests

2 participants