修复 cargo 换源的一些问题#288
Merged
Merged
Conversation
|
Hi @happy-game, ❤️ 感谢你的贡献!你的 PR 当前基于 |
ccmywish
reviewed
Sep 13, 2025
Contributor
There was a problem hiding this comment.
这个文件没有看到对应的 rawstr4c.md 变化,是不是漏 git add 进来了?
Collaborator
Author
There was a problem hiding this comment.
sorry, 我漏了没有更新这一部分, 今天晚点我更新后再上传一次
Collaborator
Author
There was a problem hiding this comment.
这部分更新了,同时我注意到这次提交里我又犯了之前 pip 的错误,也一并更正了
参考 uv 换源实现 Co-Authored-By: Claude <noreply@anthropic.com>
1. 如果存在配置文件,则过滤出 mirror 2. 如果不存在配置文件或配置文件未定义 source.mirror 则显示默认源
ccmywish
requested changes
Sep 14, 2025
|
|
||
| if (0 == status) | ||
| { | ||
| #if defined(XY_Build_On_macOS) || defined(XY_Build_On_BSD) |
Contributor
There was a problem hiding this comment.
这里还是用动态的变量 xy.on_macos 等检测吧,
考虑到可能会有跨平台编译(比如,现在安卓的chsrc是在Windows上编译的),所以专门把这几个宏从原来的 XY_On_macOS 改成了 XY_Build_On_macOS,强调是在编译时判断。
| // 尝试提取 [source.mirror] 下的 registry URL | ||
| char *grep_cmd = xy_str_gsub ("grep -A1 '\\[source\\.mirror\\]' '@f@' | grep 'registry' | cut -d'\"' -f2", "@f@", cargo_config_file); | ||
| chsrc_ensure_program ("grep"); | ||
| chsrc_ensure_program ("cut"); |
Contributor
There was a problem hiding this comment.
Windows 上似乎没有 cut,能不能换一个方法?
虽然 Windows 默认也没有 grep,但是比起 grep,用户可能更没有 cut.
| chef_set_chef (this, NULL); | ||
| chef_set_cooks (this, 1, "@ccmywish"); | ||
| chef_set_sauciers (this, 1, "@Mikachu2333"); | ||
| chef_set_sauciers (this, 2, "@Mikachu2333", "@happy-game"); |
Contributor
There was a problem hiding this comment.
cooks就是看这个文件主要是谁写的,谁改动的。sauciers是小变化,小改动。
这个文件你的改动很大,你直接写在我前面吧。
ccmywish
approved these changes
Sep 19, 2025
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.
问题描述
方案与实现
由于 uv 和 cargo 的 mirror 都是存在 toml 配置文件当中且有相似的结构,因此参考 uv 换源实现 Cargo 换源,具体如下:
对于 getsrc, 做了如下考虑: