Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 13, 2025

Addresses #652 by adding comprehensive documentation and test coverage for Pull Request (PR) resources in response to user confusion about how to use PR resources as AI context.

Problem

Users didn't understand how to properly reference pull request files as resources for AI context. The PR resource functionality existed but lacked:

  • Clear documentation explaining the URI template syntax
  • Examples showing proper usage with the path parameter
  • Comprehensive test coverage
  • Documentation of valid path values and use cases

Solution

1. Enhanced Test Coverage (pkg/github/repository_resource_test.go)

  • Added dedicated Test_GetRepositoryResourcePrContent() function to validate URI template
  • Added comprehensive test cases for PR resources:
    • successful text content fetch (pr with path) - tests nested file paths
    • pr not found error - error handling for non-existent PRs
    • invalid pr number - error handling for invalid PR numbers
  • All tests pass with proper error scenarios covered

2. Created Detailed Documentation (docs/pr-resources.md)

  • Complete guide explaining PR resource URI template: repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}
  • Parameter documentation with clear examples
  • How it works (SHA resolution process explanation)
  • Real-world use cases: code review, documentation analysis, test coverage, configuration changes
  • Error handling scenarios and limitations
  • Tips and best practices

3. Updated README with Comprehensive Resources Section

  • Added complete "Resources" section documenting all resource types
  • Dedicated Pull Request resources section with practical examples
  • Clear syntax examples showing proper usage

Examples Added

Basic PR Resource Access

repo://microsoft/vscode/refs/pull/123/head/contents/README.md
repo://facebook/react/refs/pull/456/head/contents/packages/react/src/React.js

Use Case Examples

  • Code Review: repo://owner/repo/refs/pull/789/head/contents/src/new-feature.js
  • Documentation: repo://owner/repo/refs/pull/234/head/contents/docs/api-changes.md
  • Test Coverage: repo://owner/repo/refs/pull/567/head/contents/tests/new-feature.test.js
  • Configuration: repo://owner/repo/refs/pull/890/head/contents/.github/workflows/ci.yml

Key Features Documented

Proper syntax with the correct URI template format
Parameter explanations including valid path values
Error handling and limitations clearly explained
Real-world use cases for AI context scenarios
Comprehensive test coverage for reliability

Testing

  • All existing tests continue to pass
  • New PR resource tests validate functionality and error handling
  • Build succeeds without issues
  • Documentation is consistent across all files

Impact

This change provides users with clear, comprehensive guidance on how to properly reference pull request files as resources, enabling better AI-powered code review, analysis, and automation workflows without modifying any existing functionality.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] 📖 Add documentation and tests for Pull Request resources (fixes #652) Add comprehensive documentation and examples for Pull Request resources Jul 13, 2025
Copilot AI requested a review from IrynaKulakova July 13, 2025 09:22
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