Conversation
Default branch isn't always "master".
If ref is not provided, it will get the default branch.
master should not be hardcoded.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #306 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 97 115 +18
Branches 6 9 +3
=========================================
+ Hits 97 115 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This pull request implements dynamic detection of the default branch for GitHub repositories instead of hardcoding "master". It introduces a new getDefaultBranch() function that uses the GitHub API to fetch the actual default branch name, with "master" as a fallback.
- Adds GitHub API integration to dynamically determine repository default branches
- Updates redirect logic to be async and use the detected default branch when no ref is specified
- Removes hardcoded "master" default from
getGitHubUrl()function signature
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libs/utils.ts | Adds getDefaultBranch() function and removes default "master" parameter from getGitHubUrl() |
| src/libs/redirect.ts | Updates checkRedirect() to be async and use dynamic default branch detection |
| src/libs/redirect.test.ts | Updates test functions to handle async redirect checking |
| src/server.test.ts | Updates test to use async default branch detection |
| src/server.ts | Makes checkRedirect() call async |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughConverted redirect flow to be asynchronous. Added getDefaultBranch utility using Octokit, removed default ref from getGitHubUrl, and updated checkRedirect to resolve ref via provided value or default branch (with optional token). Adjusted server and tests to await async functions and construct URLs with resolved branches. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🧰 Additional context used🧬 Code graph analysis (5)src/libs/redirect.test.ts (3)
src/libs/utils.ts (3)
src/server.ts (1)
src/libs/redirect.ts (2)
src/server.test.ts (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
close #301
✏️ Description
The default branch isn't always "master".