Skip to content

Conversation

@differentmatt
Copy link
Owner

@differentmatt differentmatt commented Feb 21, 2025

Prioritize configuration setting domainOverride over git remote info when constructing URLs. Deprecate configuration setting gitUrl and use as a fallback for domainOverride.

Prioritize configuration setting defaultBranchFallback over other lookups.

Fixes #59

Summary by CodeRabbit

  • New Features
    • Introduced a configuration option for a GitHub domain override, enabling customization for enterprise or SSH scenarios.
    • Updated the logic for default branch detection so that user-specified fallback settings are prioritized.
    • Ensured backward compatibility by maintaining support for legacy configurations.

Prioritize configuration setting domainOverride over git remote info when constructing URLs.
Deprecate configuration setting gitUrl and use as a fallback for domainOverride.

Prioritize configuration setting defaultBranchFallback over other lookups.

Fixes #59
@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2025

Walkthrough

The changes update the configuration and functionality for GitHub URL handling and default branch determination. A new property copyGithubUrl.domainOverride is introduced in the configuration, and the existing copyGithubUrl.gitUrl is marked as deprecated with an accompanying deprecation message. In the source code, the logic in getDefaultBranch and getGithubUrlFromRemotes has been revised to prioritize user-defined settings. An updated test suite confirms that the new configuration takes precedence where applicable and that fallback procedures work as expected.

Changes

File(s) Change Summary
package.json Added new property copyGithubUrl.domainOverride for specifying a GitHub domain override; updated copyGithubUrl.gitUrl to include a deprecation message and revised description.
src/main.js Modified getDefaultBranch to first use a user-provided fallback branch and renumbered subsequent steps; updated getGithubUrlFromRemotes to check for domainOverride before falling back to gitUrl, with comments adjusted accordingly.
test/unit/github.test.js Introduced tests to verify that domainOverride takes precedence over gitUrl in URL construction and that default branch determination honors the defaultBranchFallback configuration, ensuring proper fallback to Git config when needed.

Sequence Diagram(s)

GitHub URL Determination

sequenceDiagram
    participant User
    participant Main
    participant Config
    participant GitRemote

    User->>Main: Trigger URL generation
    Main->>Config: Retrieve "domainOverride"
    alt domainOverride exists
        Config-->>Main: Return domainOverride value
        Main->>GitRemote: Construct URL using domainOverride
    else
        Main->>Config: Retrieve "gitUrl"
        Config-->>Main: Return gitUrl value
        Main->>GitRemote: Construct URL using gitUrl
    end
    Main->>User: Return constructed Git URL
Loading

Default Branch Determination

sequenceDiagram
    participant User
    participant Main
    participant Config
    participant GitConfig

    User->>Main: Request default branch
    Main->>Config: Check for defaultBranchFallback
    alt defaultBranchFallback exists
        Config-->>Main: Return fallback branch
    else
        Main->>GitConfig: Read from .git/config
        GitConfig-->>Main: Return default branch from config
    end
    Main->>User: Return default branch
Loading

Poem

I'm a rabbit, hopping through lines of code so neat,
New overrides and fallbacks make my journey extra sweet.
Deprecated paths bow down to the shiny domain,
While branch fallbacks guide me like a gentle refrain.
CodeRabbit celebrates every clever tweak and hop,
In a world where progress never stops! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c91cc2f and f18b5cb.

📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/main.js (5 hunks)
  • test/unit/github.test.js (1 hunks)
🔇 Additional comments (8)
src/main.js (2)

75-78: LGTM! Improved default branch determination.

The change prioritizes user configuration by checking defaultBranchFallback first, which aligns with the PR objectives and provides better control to users.


167-167: LGTM! Implemented domainOverride with backward compatibility.

The changes correctly implement the new domainOverride setting while maintaining backward compatibility with gitUrl. The implementation:

  1. Checks domainOverride first, falling back to gitUrl
  2. Uses the override for URL construction
  3. Maintains existing functionality when neither setting is present

Also applies to: 180-181, 186-192, 200-203

test/unit/github.test.js (4)

793-812: LGTM! Comprehensive test for domainOverride precedence.

The test correctly verifies that domainOverride takes precedence over gitUrl, ensuring the new configuration works as intended.


814-833: LGTM! Proper backward compatibility test.

The test validates the fallback behavior to gitUrl when domainOverride is not set, ensuring backward compatibility.


835-853: LGTM! Thorough defaultBranchFallback test.

The test ensures that defaultBranchFallback configuration takes precedence over git config, aligning with the changes in main.js.


855-879: LGTM! Complete fallback chain test.

The test verifies the correct fallback behavior when defaultBranchFallback is not configured, ensuring robust branch determination.

package.json (2)

67-70: LGTM! Clear domainOverride configuration.

The new configuration is well-documented with a clear description and example.


73-74: LGTM! Proper deprecation notice.

The deprecation is clearly communicated with both a description update and a deprecation message.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@differentmatt differentmatt merged commit 89a0ede into main Feb 21, 2025
2 checks passed
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.

Settings > Copy Github Url does not work as expected

2 participants