Add comprehensive documentation and examples for Pull Request resources #677
+291
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
path
parameterSolution
1. Enhanced Test Coverage (
pkg/github/repository_resource_test.go
)Test_GetRepositoryResourcePrContent()
function to validate URI templatesuccessful text content fetch (pr with path)
- tests nested file pathspr not found error
- error handling for non-existent PRsinvalid pr number
- error handling for invalid PR numbers2. Created Detailed Documentation (
docs/pr-resources.md
)repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}
3. Updated README with Comprehensive Resources Section
Examples Added
Basic PR Resource Access
Use Case Examples
repo://owner/repo/refs/pull/789/head/contents/src/new-feature.js
repo://owner/repo/refs/pull/234/head/contents/docs/api-changes.md
repo://owner/repo/refs/pull/567/head/contents/tests/new-feature.test.js
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
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.