feat(core): Add support for Azure DevOps remote repository URLs#881
feat(core): Add support for Azure DevOps remote repository URLs#881
Conversation
This commit adds support for Azure DevOps repository URLs in both SSH and HTTPS formats. Azure DevOps uses a special URL structure that differs from standard Git hosting services: - SSH: git@ssh.dev.azure.com:v3/organization/project/repo - HTTPS: https://dev.azure.com/organization/project/_git/repo The git-url-parse library can parse these URLs but its toString() method doesn't preserve the full path structure (e.g., v3/organization/ part is lost in SSH URLs). To address this, we now detect Azure DevOps URLs by checking the source field and use the original URL as-is instead of reconstructing it. Changes: - Modified parseRemoteValue() to use switch statement for source-based URL handling - Added Azure DevOps cases ('dev.azure.com' and 'azure.com') to preserve original URLs - Added test cases for both Azure DevOps SSH and HTTPS URL formats - All existing tests continue to pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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. WalkthroughUpdated devcontainer to remove ESLint/Prettier extensions and related on-save settings. Modified git remote parsing to handle Azure DevOps URLs by preserving the original URL and avoiding .git suffix logic. Added tests covering Azure DevOps SSH and HTTPS URL handling with undefined remoteBranch. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant P as parseRemoteValue
participant U as URL Parser
C->>P: parseRemoteValue(remoteValue)
P->>U: parse(remoteValue)
U-->>P: parsedFields (host, owner, repo, protocol, ...)
alt Host is Azure DevOps (dev.azure.com / azure.com)
note right of P: New handling
P->>P: repoUrl = original remoteValue<br/>remoteBranch = undefined
else Other hosts
P->>P: Enable git_suffix, validate owner/repo
P->>P: repoUrl = parsedFields.toString(protocol)
end
P-->>C: { repoUrl, remoteBranch, ... }
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
Summary of ChangesHello @yamadashy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces crucial enhancements to the core git remote parsing logic, specifically enabling accurate interpretation and handling of Azure DevOps repository URLs. By adjusting how these unique URL formats are processed, the system can now correctly identify and utilize Azure DevOps remotes, ensuring compatibility and robustness. Additionally, the PR includes minor maintenance updates to development environment configurations and CI workflows. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull Request Overview
Adds Azure DevOps remote URL support to the git remote parser while preserving original URL structure for hosts where the parser would otherwise lose critical path segments.
- Adds conditional handling for Azure DevOps URLs in parseRemoteValue
- Introduces unit tests for Azure DevOps SSH and HTTPS formats
- Cleans up devcontainer configuration by removing formatting extensions/settings
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/core/git/gitRemoteParse.ts | Adds switch logic to special-case Azure DevOps remotes |
| tests/core/git/gitRemoteParse.test.ts | Adds tests for SSH and HTTPS Azure DevOps remote formats |
| .devcontainer/devcontainer.json | Removes editor extensions and formatting settings |
src/core/git/gitRemoteParse.ts
Outdated
| // - HTTPS: https://dev.azure.com/organization/project/_git/repo | ||
| // The parser's toString() method doesn't preserve the full path, so use the original URL | ||
| case 'dev.azure.com': | ||
| case 'azure.com': |
There was a problem hiding this comment.
The SSH host shown in the comment (ssh.dev.azure.com) is not handled in the switch, so SSH Azure DevOps URLs will fall through to the default branch and be incorrectly transformed. Add a case for 'ssh.dev.azure.com' (and consider removing the unexplained 'azure.com' case) so the original URL is preserved: case 'ssh.dev.azure.com': case 'dev.azure.com': repoUrl = remoteValue;.
| case 'azure.com': | |
| case 'ssh.dev.azure.com': |
There was a problem hiding this comment.
Code Review
This pull request adds support for parsing Azure DevOps remote repository URLs. The approach of using a switch statement to detect these URLs and preserve the original string is sound. However, the implementation doesn't fully cover all Azure DevOps URL formats. Specifically, SSH URLs (e.g., git@ssh.dev.azure.com/...) and legacy visualstudio.com URLs are not correctly handled. I've provided a suggestion to fix this in gitRemoteParse.ts and also recommended adding a new test case to ensure legacy URLs are covered.
Code Review for PR #881: Azure DevOps Remote Repository URL SupportThank you for adding Azure DevOps support! This is a valuable addition to Repomix. Here's my review: ✅ Strengths
🔍 Suggestions for Improvement1. Consider additional Azure DevOps URL formatsAzure DevOps (and its predecessor Visual Studio Team Services) supports several URL formats that aren't currently handled:
Consider whether these formats should be supported for broader compatibility. 2. Edge case: 'azure.com' source matchingThe current implementation matches both
3. Branch/ref handling for Azure DevOps URLsThe current implementation preserves the original URL but doesn't handle refs/branches that might be in Azure DevOps URLs. While the basic URLs are handled correctly, consider testing URLs with branches/refs to ensure they work as expected. 4. Test for edge casesConsider adding tests for:
📝 Minor NotesDev container changesThe removal of ESLint and Prettier extensions from the dev container seems unrelated to this PR. While not necessarily problematic (since the workspace likely has these settings), consider whether this change should be in a separate PR for clarity. ✅ Overall AssessmentThe implementation is solid and follows the existing code patterns well. The PR achieves its goal of adding Azure DevOps support effectively. The suggestions above are mostly about enhancing coverage for edge cases and ensuring robustness. Recommendation: Approve with minor suggestions for consideration in future iterations. Great work on this feature! 🚀 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #881 +/- ##
==========================================
+ Coverage 88.81% 88.84% +0.03%
==========================================
Files 109 109
Lines 7580 7604 +24
Branches 1425 1435 +10
==========================================
+ Hits 6732 6756 +24
Misses 848 848 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/core/git/gitRemoteParse.test.ts (1)
52-68: Consider adding edge case tests for Azure DevOps URLs.The current tests cover the basic happy path for Azure DevOps SSH and HTTPS URLs. Consider adding tests for:
- Azure DevOps URLs with
.gitsuffix to verify how they're handled- Malformed Azure DevOps URLs to ensure proper error handling
- Azure DevOps URLs with branch/tag references (if supported by the platform)
Example test cases:
test('should handle Azure DevOps URLs with .git suffix', () => { const azureDevOpsUrl = 'https://dev.azure.com/organization/project/_git/repo.git'; const parsed = parseRemoteValue(azureDevOpsUrl); expect(parsed).toEqual({ repoUrl: azureDevOpsUrl, remoteBranch: undefined, }); }); test('should handle Azure DevOps URLs with branch parameter', () => { const azureDevOpsUrl = 'https://dev.azure.com/organization/project/_git/repo?version=GBmain'; const parsed = parseRemoteValue(azureDevOpsUrl); // Verify expected behavior for branch handling });src/core/git/gitRemoteParse.ts (1)
44-47: Consider adding validation for Azure DevOps URLs.Unlike the default case (lines 53-58), the Azure DevOps case bypasses all validation and directly uses the original
remoteValue. While preserving the original URL is necessary due to Azure DevOps's complex path structure, consider adding basic validation to ensure the URL is well-formed and not malicious.For example:
- Verify the URL structure matches expected Azure DevOps patterns
- Check for suspicious path components
- Validate that the URL uses HTTPS or SSH protocols only
Example validation:
case 'dev.azure.com': case 'azure.com': + // Basic validation for Azure DevOps URL structure + if (parsedFields.protocol !== 'https' && parsedFields.protocol !== 'ssh') { + throw new RepomixError('Invalid Azure DevOps URL: only HTTPS and SSH protocols are supported'); + } repoUrl = remoteValue; break;
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.devcontainer/devcontainer.json(0 hunks)src/core/git/gitRemoteParse.ts(1 hunks)tests/core/git/gitRemoteParse.test.ts(1 hunks)
💤 Files with no reviewable changes (1)
- .devcontainer/devcontainer.json
🧰 Additional context used
🧬 Code graph analysis (2)
tests/core/git/gitRemoteParse.test.ts (1)
src/core/git/gitRemoteParse.ts (1)
parseRemoteValue(22-86)
src/core/git/gitRemoteParse.ts (1)
src/shared/errorHandle.ts (1)
RepomixError(6-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Memory Test
- GitHub Check: Build and run with Bun (windows-latest, latest)
- GitHub Check: Build and run (windows-latest, 22.x)
- GitHub Check: Test coverage
- GitHub Check: claude-review
🔇 Additional comments (1)
src/core/git/gitRemoteParse.ts (1)
37-63: Good implementation of Azure DevOps URL handling.The switch statement clearly separates Azure DevOps URL handling from standard Git URLs, with helpful comments explaining why the original URL must be preserved. The default case maintains existing validation logic, ensuring backward compatibility.
Address PR review feedback by expanding Azure DevOps URL support: - Add support for SSH URLs (ssh.dev.azure.com) - Add support for legacy Visual Studio Team Services (*.visualstudio.com) - Remove invalid azure.com case - Add test coverage for legacy VSTS URLs - Move Azure DevOps detection before git-url-parse to avoid parsing issues This ensures compatibility with all Azure DevOps URL formats including modern and legacy domains.
Deploying repomix with
|
| Latest commit: |
3a10a9f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ad6dc1bc.repomix.pages.dev |
| Branch Preview URL: | https://feat-azure-dev-ops.repomix.pages.dev |
Code Review for PR #881: Azure DevOps Remote Repository URL SupportThank you for addressing issue #848 and adding Azure DevOps support to Repomix! This is a valuable addition that will help users working with Azure DevOps repositories. ✅ Strengths
🔍 Issues and Suggestions1. Incomplete Azure DevOps URL detectionThe current implementation uses a switch statement on parsedFields.host, but this will not catch SSH URLs correctly. For SSH URLs like git@ssh.dev.azure.com:v3/org/project/repo, the parser likely extracts ssh.dev.azure.com as the host, not dev.azure.com. Recommended fix (src/core/git/gitRemoteParse.ts:34-47): // Check for Azure DevOps URLs before parsing, as git-url-parse may not handle them correctly
// - SSH: git@ssh.dev.azure.com:v3/org/project/repo
// - HTTPS: https://dev.azure.com/organization/project/_git/repo
// - Legacy: https://org.visualstudio.com/project/_git/repo
const isAzureDevOpsUrl =
remoteValue.includes("dev.azure.com") ||
remoteValue.includes("ssh.dev.azure.com") ||
remoteValue.includes(".visualstudio.com");
if (isAzureDevOpsUrl) {
return {
repoUrl: remoteValue,
remoteBranch: undefined,
};
}2. Missing test for legacy Visual Studio Team Services URLsWhile the code comments mention legacy VSTS URLs, there is no test case for them. Consider adding: test("should handle legacy Visual Studio Team Services URLs", () => {
const vstsUrl = "https://myorg.visualstudio.com/myproject/_git/myrepo";
const parsed = parseRemoteValue(vstsUrl);
expect(parsed).toEqual({
repoUrl: vstsUrl,
remoteBranch: undefined,
});
});3. Consider URL validationUnlike the default case which validates owner and repo names, Azure DevOps URLs bypass all validation. Consider adding basic validation to ensure the URLs are well-formed. 4. Edge cases to consider testing
📝 Minor NotesThe devcontainer configuration changes (removing ESLint/Prettier extensions) appear unrelated to this PR main purpose. While not problematic, consider whether these should be in a separate PR for clarity. ✅ Overall AssessmentThe implementation is on the right track and follows the existing code patterns well. However, the SSH URL detection issue needs to be addressed for the feature to work correctly with all Azure DevOps URL formats. Once that is fixed, this will be a solid addition to Repomix. Recommendation: Request changes - the SSH URL detection needs to be fixed before merging. Great work on tackling this feature! The approach is sound, just needs the detection logic adjustment. 🚀 |
Replace substring matching with proper URL parsing to fix CodeQL security alert. Previously, the code used `includes()` for substring matching which could incorrectly identify malicious URLs like `https://evil.com/dev.azure.com/` as Azure DevOps URLs. Changes: - Extract Azure DevOps URL detection into a dedicated function - Use URL constructor to parse and validate the hostname - For SSH URLs, use `startsWith()` for exact prefix matching - For HTTP(S) URLs, check the hostname property exactly - Add security tests to ensure malicious URLs are not incorrectly identified This resolves the "Incomplete URL substring sanitization" alert from CodeQL.
Code Review for PR #881: Azure DevOps SupportThank you for implementing support for Azure DevOps remote repository URLs! This is a valuable addition that addresses issue #848. Here's my review: ✅ Strengths
🔍 Suggestions for Improvement
🎯 Performance & Security
📝 Code Quality
✅ Overall AssessmentThis is a well-implemented feature that thoughtfully addresses the Azure DevOps URL parsing issue. The security-first approach and comprehensive testing make this a solid contribution. The changes are minimal, focused, and follow the project's coding guidelines. Approved - Ready to merge after considering the minor suggestions above (which are optional improvements, not blockers). Great work on this implementation! 🎉 |
fix:
This PR adds support for Azure DevOps remote repository URLs in the git remote parser.
Azure DevOps uses special URL formats:
git@ssh.dev.azure.com:v3/org/project/repohttps://dev.azure.com/organization/project/_git/repoThe existing git URL parser's
toString()method doesn't preserve the full path structure needed for Azure DevOps URLs, so this PR modifies the parser to use the original URL when Azure DevOps is detected.Changes
gitRemoteParse.tsto detect Azure DevOps URLs and use the original URL instead of the parsed outputChecklist
npm run testnpm run lint