fix(git): support git@ SSH URLs with regression-safe repo detection (#317)#385
Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom Mar 2, 2026
Merged
Conversation
…317) - Add git@ SSH URL parsing to parse_code_hosting_url() - Add git@ support to is_code_hosting_url() (clean, no try/except) - Add validate_git_ssh_uri() for early format validation - Add is_git_repo_url() for strict cloneable-repo detection: * git@/ssh://git:// protocols: always repo if domain matches * https URLs: require exactly /owner/repo path (2 segments) * Prevents regression: /issues/, /pull/, /blob/ etc. are NOT repos - Update media_processor routing to use CodeRepositoryParser for git repos - Update CLI resource handler to recognize git@ URLs - Update CodeRepositoryParser.parse() to handle git@ directly - Enhance _run_git() errors: keep command info, add friendly messages - Add 20 comprehensive tests covering all new functions Fixes #317 Addresses review comments from PR #375 (regression risk, test coverage, error message preservation, SSH/HTTP path consistency)
19 tasks
MaojiaSheng
approved these changes
Mar 2, 2026
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix CLI's inability to recognize
git@domain:repo.gitformat URLs (Issue #317).This PR takes a different approach from #375 by introducing a strict
is_git_repo_url()function that prevents the regression identified by @qin-ctx — HTTPS URLs likehttps://github.com/org/repo/issues/123are correctly not routed toCodeRepositoryParser.Related Issue
Fixes #317
Key Design Decisions
Regression-safe routing via
is_git_repo_url()git@,ssh://,git://protocols → always treated as git repos (if domain matches)https://URLs → only treated as repos when path has exactly 2 segments (/owner/repo)/issues/,/pull/,/blob/are not routed to git cloneAddresses all review comments from PR #375
is_git_repo_url()strict path checkCommand: git {args}. Details: {error}return FalseChanges Made
code_hosting_utils.pyparse_code_hosting_url,is_code_hosting_url; newvalidate_git_ssh_uri,is_git_repo_url__init__.pymedia_processor.py_is_url(); route toCodeRepositoryParserin_process_url()resources.pycode.pyparse(); enhanced error messages with command infotest_code_hosting_utils.pyTesting
Test coverage includes:
git@github.com:org/repo.git→ correctly parsed asorg/repogit@unknown.com:org/repo.git→ rejected (unknown domain)git@github.com:repo→ rejected (single segment)https://github.com/org/repo→ recognized as repohttps://github.com/org/repo/issues/123→ NOT a repo (regression test)https://github.com/org/repo/pull/456→ NOT a repo (regression test)https://github.com/org/repo/blob/main/file.py→ NOT a repo (regression test)