PR File Relationships
A VS Code extension that analyzes GitHub Pull Request history to show you the top related files based on how often they're modified together in PRs.
Features
- Automatic PR Analysis: Fetches and analyzes merged PRs from your GitHub repository
- Related Files Tree View: Shows the top 10 files most frequently changed together with your current file
- Quick Pick Menu: Quickly jump to related files with
Cmd+Shift+P → "PR Relations: Show Related Files"
- Status Bar Integration: See how many related files exist for your current file at a glance
- Configurable Weight Threshold: Filter relationships by minimum edge weight (how many times files changed together)
- Local Caching: Cache PR data locally to avoid repeated GitHub API calls
Prerequisites
This extension requires the github-pr-graph Go binary to be built in your workspace:
go build -o github-pr-graph main.go
Make sure you have:
- Go installed
- GitHub token set (either
GITHUB_TOKEN env var or gh CLI logged in)
Usage
1. Analyze PRs
First, analyze PRs from your repository:
- Open Command Palette (
Cmd+Shift+P / Ctrl+Shift+P)
- Run "PR Relations: Analyze PRs"
- Enter your GitHub owner and repo when prompted (or configure in settings)
The extension will:
- Run the
github-pr-graph tool
- Parse the generated graph data
- Build an adjacency map of file relationships
Once analysis is complete, you have two ways to see related files:
- Click the PR Relationships icon in the activity bar
- Open any file in your workspace
- The tree view automatically shows the top 10 related files
- Open a file
- Run "PR Relations: Show Related Files" command
- Select a file from the list to open it
3. Status Bar
The status bar shows:
- Number of related files for the current file
- Number of PRs the file appeared in
- Click it to show the quick pick menu
Configuration
Configure the extension in your workspace settings (.vscode/settings.json):
{
"prFileRelationships.owner": "Zomato",
"prFileRelationships.repo": "search-service",
"prFileRelationships.numPRs": 100,
"prFileRelationships.baseBranch": "dev",
"prFileRelationships.minWeight": 2,
"prFileRelationships.topN": 10
}
Settings
| Setting |
Default |
Description |
owner |
"" |
GitHub repository owner |
repo |
"" |
GitHub repository name |
numPRs |
100 |
Number of PRs to analyze |
baseBranch |
"dev" |
Base branch to filter merged PRs |
minWeight |
2 |
Minimum edge weight (files must have changed together at least this many times) |
topN |
10 |
Number of top related files to show |
Commands
| Command |
Description |
PR Relations: Analyze PRs |
Fetch and analyze PRs (uses cache if available) |
PR Relations: Show Related Files |
Show quick pick menu of related files for current file |
PR Relations: Refresh Cache |
Re-fetch PRs from GitHub and update cache |
How It Works
- Data Collection: The Go tool fetches merged PRs and files changed in each PR
- Graph Building: Creates a graph where:
- Nodes = files
- Edges = files changed in the same PR
- Edge weight = number of PRs both files appeared in together
- Relationship Detection: For any file, finds connected files with weight above threshold
- Ranking: Sorts by weight (descending) and shows top N results
Example
If main.go and config.yaml were both modified in 5 different PRs:
- Edge weight = 5
- When viewing
main.go, config.yaml appears in related files with weight 5
- If
minWeight = 2, this relationship will be shown
Tips
- Start with cached analysis: Use
--cache flag for faster subsequent runs
- Adjust minWeight: Higher values show only strongly related files
- Increase numPRs: More PRs = better relationship detection, but slower analysis
- Use for code reviews: Quickly find files that often change together to understand dependencies
Development
Running the Extension
- Open this folder in VS Code
- Press
F5 to open a new window with the extension loaded
- In the Extension Development Host window, open a workspace with the Go binary
- Run "PR Relations: Analyze PRs" to test
Building
npm run compile
Packaging
npm run package
vsce package
License
MIT