Skip to content

Commit 44dcebf

Browse files
authored
Merge pull request #189 from Kattos/main
- remove useless error messages when `uv` is set but no config file exists - Fixed #188
2 parents b70e0c4 + 340928f commit 44dcebf

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/chsrc-main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* | juzeon <[email protected]>
2424
* | Jialin Lyu <[email protected]>
2525
* | GitHub Copilot <https://github.com/copilot>
26+
2627
* |
2728
* Created On : <2023-08-28>
2829
* Last Modified : <2025-03-25>
@@ -851,4 +852,4 @@ main (int argc, char const *argv[])
851852
chsrc_error (msg);
852853
return Exit_Unknown;
853854
}
854-
}
855+
}

src/recipe/lang/Python/uv.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,24 @@ pl_python_uv_setsrc (char *option)
9494
uv_config);
9595
char *append_source_cmd = xy_strjoin (4, "printf '", source_content, "' >> ", uv_config);
9696

97-
// grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
98-
// 如果 uv_config 中存在 [[index]] 则更新, 否则追加到文件末尾
99-
// 文件不存在也是追加到新文件末尾
100-
char *cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
101-
uv_config,
102-
" && ",
103-
update_source_cmd,
104-
" || ",
105-
append_source_cmd);
97+
char *cmd = NULL;
98+
if (!xy_file_exist (uv_config))
99+
{
100+
// uv_config 不存在,追加到新文件末尾
101+
// run: append_source_cmd
102+
cmd = append_source_cmd;
103+
}
104+
else
105+
{
106+
// uv_config 存在,如果存在 [[index]] 则更新,否则追加到文件末尾
107+
// run: grep -q '^[[index]]$' uv_config && update_source_cmd || append_source_cmd
108+
cmd = xy_strjoin (6, "grep -q '^\\[\\[index\\]\\]$' ",
109+
uv_config,
110+
" && ",
111+
update_source_cmd,
112+
" || ",
113+
append_source_cmd);
114+
}
106115

107116
chsrc_run (cmd, RunOpt_Default);
108117

0 commit comments

Comments
 (0)