Skip to content

Conversation

@Kattos
Copy link
Contributor

@Kattos Kattos commented Apr 2, 2025

描述

问题的背景

当前 chsrc set uv 命令存在两个问题

  • 当 uv.toml 不存在时,chsrc set uv 向该文件写入了错误的内容
# chsrc set uv tuna
-e [[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true
  • 当 uv.toml 存在时,由于命令执行错误导致 chsrc set uv 本意修改 [[index]] 当前的 url,实际上会添加了一个新的 [[index]]
# chsrc set uv tuna
-e [[index]]
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
default = true

# chsrc set uv pku
-e [[index]]
url = "https://mirrors.pku.edu.cn/pypi/web/simple"
default = true

相关 issue

N/A

这个PR做了什么

修复了上述两个问题,在更新 ~/.config/uv/uv.toml 时避免错误写 or 重复写

方案

实现

  • 使用 printf 命令代替 echo -e 避免向文件中写入 '-e'
  • 修改错误的 sed 命令避免向文件中写入冗余的 '[[index]]'

测试

  • 运行 chsrc set uv xxx 验证 uv.toml 是否正确更新

@ccmywish ccmywish added the pl_target pl target label Apr 2, 2025
@ccmywish ccmywish added this to the v0.2.1 milestone Apr 2, 2025
@ccmywish ccmywish requested a review from happy-game April 2, 2025 12:16
@ccmywish ccmywish mentioned this pull request Apr 2, 2025
@ccmywish
Copy link
Contributor

ccmywish commented Apr 2, 2025

@Kattos 这是你参与本项目的第一步,为 chsrc 注入了新的活力!👍

@happy-game 有空帮忙看下这个PR吗?🤝


可能的原因:

#187echosh 时呈现了不同的行为

@happy-game
Copy link
Collaborator

这个 pr 我测试过没有问题👍!

@happy-game happy-game changed the base branch from main to dev April 2, 2025 13:29
@happy-game happy-game merged commit b70e0c4 into RubyMetric:dev Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pl_target pl target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants