|
7 | 7 | * | |
8 | 8 | * Created On : <2024-12-11> |
9 | 9 | * Major Revision : 1 |
10 | | - * Last Modified : <2025-07-14> |
| 10 | + * Last Modified : <2025-07-26> |
11 | 11 | * ------------------------------------------------------------*/ |
12 | 12 |
|
13 | 13 | /** |
@@ -115,49 +115,34 @@ pl_python_uv_setsrc (char *option) |
115 | 115 | /** |
116 | 116 | * 将 [[index]] 到 default = true 之间的 url = ".*" 替换为 url = "source.url" |
117 | 117 | */ |
118 | | - char *update_source_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config, "@sed@", sed_cmd); |
119 | | - update_source_cmd = xy_str_gsub (update_source_cmd, "@f@", uv_config); |
120 | | - update_source_cmd = xy_str_gsub (update_source_cmd, "@url@", source.url); |
| 118 | + char *update_config_cmd = xy_str_gsub (RAWSTR_pl_python_set_uv_config, "@sed@", sed_cmd); |
| 119 | + update_config_cmd = xy_str_gsub (update_config_cmd, "@f@", uv_config); |
| 120 | + update_config_cmd = xy_str_gsub (update_config_cmd, "@url@", source.url); |
121 | 121 |
|
122 | | - char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config); |
| 122 | + char *append_config_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config); |
123 | 123 |
|
124 | | - char *cmd = NULL; |
125 | 124 | if (!xy_file_exist (uv_config)) |
126 | 125 | { |
127 | | - /** |
128 | | - * uv_config 不存在,追加到新文件末尾 |
129 | | - * run: append_source_cmd |
130 | | - */ |
131 | | - cmd = append_source_cmd; |
| 126 | + /* 当 uv_config 不存在,直接写入文件 */ |
| 127 | + chsrc_append_to_file (source_content, uv_config); |
132 | 128 | } |
133 | 129 | else |
134 | 130 | { |
135 | | - if (xy_on_windows) |
| 131 | + /* 当 uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 */ |
| 132 | + char *cmd = xy_str_gsub (RAWSTR_pl_python_test_uv_if_set_source, "@f@", uv_config); |
| 133 | + chsrc_ensure_program ("grep"); |
| 134 | + int status = system (cmd); |
| 135 | + if (0==status) |
136 | 136 | { |
137 | | - /* TODO: Windows 下替换源暂不支持 */ |
138 | | - chsrc_note2 ("Windows 下暂不支持修改 uv.toml,请手动修改配置文件"); |
| 137 | + chsrc_run (update_config_cmd, RunOpt_Default); |
139 | 138 | } |
140 | 139 | else |
141 | 140 | { |
142 | | - /** |
143 | | - * uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾 |
144 | | - */ |
145 | | - cmd = xy_str_gsub (RAWSTR_pl_python_final_uv_cmd, "@f@", uv_config); |
146 | | - cmd = xy_str_gsub (cmd, "@ucmd@", update_source_cmd); |
147 | | - cmd = xy_str_gsub (cmd, "@acmd@", append_source_cmd); |
| 141 | + chsrc_append_to_file (source_content, uv_config); |
148 | 142 | } |
149 | 143 | } |
150 | | - if (NULL==cmd) |
151 | | - { |
152 | | - chsrc_note2 (xy_strjoin (4, "请手动为 ", uv_config, "添加或修改 [[index]] 配置项的 url = ", source.url)); |
153 | | - } |
154 | | - else |
155 | | - { |
156 | | - chsrc_run (cmd, RunOpt_Default); |
157 | | - } |
158 | 144 |
|
159 | | - |
160 | | - if(chsrc_in_standalone_mode()) |
| 145 | + if (chsrc_in_standalone_mode()) |
161 | 146 | { |
162 | 147 | chsrc_determine_chgtype (ChgType_Auto); |
163 | 148 | chsrc_conclude (&source); |
|
0 commit comments