Table of Contents
PR Review Utility - Phase 1
A .NET Core 5 web application for fetching and reviewing BitBucket Pull Request diffs.
Features (Phase 1)
✅ Fetch PR Details - Get pull request metadata from BitBucket ✅ View Diff - Display file-by-file changes with syntax highlighting ✅ Export Diff - Download diff as .txt file for AI review ✅ Parse Changes - Automatically count additions/deletions per file ✅ Simple UI - Clean HTML/JS interface with Bootstrap 5
Prerequisites
- .NET 5.0 SDK or later
- BitBucket account with API access
- BitBucket App Password (for authentication)
Setup Instructions
1. Clone/Download the Project
cd PRReviewUtility
2. Configure BitBucket Credentials
Edit appsettings.json and update the BitBucket section:
{
"BitBucket": {
"BaseUrl": "https://api.bitbucket.org/2.0",
"Workspace": "your-workspace-name",
"Username": "your-bitbucket-username",
"AppPassword": "your-app-password"
}
}
How to get BitBucket App Password:
- Go to BitBucket → Personal Settings → App Passwords
- Click "Create app password"
- Select permissions:
Pull requests: Read,Repositories: Read - Copy the generated password
3. Restore Dependencies
dotnet restore
4. Build the Project
dotnet build
5. Run the Application
dotnet run
The application will start at:
- HTTPS:
https://localhost:5001 - HTTP:
http://localhost:5000
Usage
Web Interface
- Open browser and navigate to
http://localhost:5000 - Enter:
- Repository Slug: The repository name (e.g.,
my-project) - Pull Request ID: The numeric PR ID (e.g.,
42)
- Repository Slug: The repository name (e.g.,
- Click Fetch Diff
- View the results:
- PR details (title, author, branches)
- List of changed files
- Individual file diffs
- Raw unified diff
- Use Export Diff to download as .txt file for AI review
API Endpoints
Get PR Details
GET /api/pr/{repository}/{prId}
Example:
curl http://localhost:5000/api/pr/my-repo/42
Get Parsed Diff
GET /api/pr/{repository}/{prId}/diff
Returns JSON with parsed files and statistics.
Get Raw Diff
GET /api/pr/{repository}/{prId}/diff/raw
Returns plain text unified diff format.
Export Diff
GET /api/pr/{repository}/{prId}/export
Downloads a .txt file with PR details and full diff.
Project Structure
PRReviewUtility/
├── Controllers/
│ ├── HomeController.cs # Serves the UI
│ └── PRController.cs # API endpoints
├── Models/
│ ├── BitBucketConfig.cs # Configuration model
│ ├── PullRequest.cs # PR data model
│ └── DiffFile.cs # Diff data models
├── Services/
│ ├── IBitBucketService.cs # Service interface
│ └── BitBucketService.cs # BitBucket API integration
├── Views/
│ ├── Home/
│ │ └── Index.cshtml # Main UI
│ └── Shared/
│ └── _Layout.cshtml # Layout template
├── wwwroot/
│ ├── css/
│ │ └── site.css # Custom styles
│ └── js/
│ ├── pr-viewer.js # UI logic
│ └── site.js # Global scripts
├── appsettings.json # Configuration
├── Program.cs # Application entry
└── Startup.cs # Service configuration
Deployment
IIS Deployment
- Publish the application:
dotnet publish -c Release -o ./publish
Copy the
publishfolder to your IIS serverCreate a new IIS site pointing to the publish folder
Ensure the Application Pool is set to "No Managed Code"
Update
appsettings.jsonin the publish folder with production credentials
Nginx Deployment (Linux)
- Publish the application:
dotnet publish -c Release -o ./publish
- Create a systemd service file
/etc/systemd/system/prreview.service:
[Unit]
Description=PR Review Utility
[Service]
WorkingDirectory=/var/www/prreview
ExecStart=/usr/bin/dotnet /var/www/prreview/PRReviewUtility.dll
Restart=always
RestartSec=10
SyslogIdentifier=prreview
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
- Configure Nginx as reverse proxy:
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Local Development
Simply run:
dotnet run
Or with hot reload:
dotnet watch run
Troubleshooting
Authentication Errors
If you get 401 Unauthorized errors:
- Verify your BitBucket username and app password in appsettings.json
- Ensure the app password has correct permissions
- Check that the workspace name is correct
Repository Not Found
If you get 404 errors:
- Verify the repository slug is correct (it's case-sensitive)
- Ensure you have access to the repository
- Check that the PR ID exists
CORS Issues
If running from a different domain:
- The application includes CORS policy
- Update the CORS configuration in Startup.cs if needed
Next Phases
Phase 2: Rule Engine (Upcoming)
- Configure ignore patterns per repository
- Define review checklists
- Apply automated filtering
- JSON-based rule configuration
Phase 3: AI Integration (Upcoming)
- Integrate with AI APIs (OpenAI, Anthropic, etc.)
- Smart token management
- Automated code review suggestions
- Intelligent diff chunking
License
MIT License
Support
For issues or questions, please check:
- BitBucket API Documentation: https://developer.atlassian.com/cloud/bitbucket/rest/
- .NET Core Documentation: https://docs.microsoft.com/dotnet/core/