feat: support GitHub tree/<ref> URL for code repository import#400
Merged
MaojiaSheng merged 1 commit intovolcengine:mainfrom Mar 3, 2026
Merged
Conversation
MaojiaSheng
approved these changes
Mar 3, 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.
Background
Previously, only plain repository URLs (https://github.com/user/repo) were recognized as code repositories. URLs containing a specific branch or commit ref (e.g.,
https://github.com/user/repo/tree/main) were routed to HTMLParser and treated as regular web pages, making it impossible to import a specific version of a repository.
Changes
openviking/utils/code_hosting_utils.py
Extended is_git_repo_url to recognize owner/repo/tree/ URLs in addition to plain owner/repo URLs. Only exactly 4-segment paths with tree at position 2 are matched,
avoiding false positives like /blob/, /issues/, or deeper sub-paths.
openviking/parse/parsers/code/code.py
characters), it is placed in the commit field; otherwise it goes to branch. This ensures non-GitHub hosts use the correct git operation (--branch for branches, fetch +
checkout for SHAs).
Usage
branch
client.add_resource("https://github.com/user/repo/tree/main")
commit SHA (short or full)
client.add_resource("https://github.com/user/repo/tree/ab849f44f252e65b2ea3106322c235d8c2f349ad")
client.add_resource("https://github.com/user/repo/tree/ab849f4")