mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-18 05:27:38 +08:00
Use original yield source
This commit is contained in:
parent
4b5aff7862
commit
b543c124be
@ -51,6 +51,8 @@ TargetGroupMode =
|
||||
};
|
||||
|
||||
bool chsrc_in_target_group_mode() {return TargetGroupMode.in;}
|
||||
// 并非作为 follower target,而是自身作为一个独立的 target 执行
|
||||
bool chsrc_in_standalone_mode() {return !TargetGroupMode.in;}
|
||||
void chsrc_set_target_group_mode(){TargetGroupMode.in = true;}
|
||||
|
||||
|
||||
@ -855,13 +857,14 @@ source_has_empty_url (Source_t *source)
|
||||
* 3. 用户什么都没指定, 即 chsrc set <target>
|
||||
* 4. 用户正在重置源, 即 chsrc reset <target>
|
||||
*
|
||||
* 如果处于 Target Group 模式下,leader target 可能会指定一个源,因此还有一种情况:
|
||||
* 如果处于 Target Group 模式下,leader target 已经测速过了,follower target 不能再次测速,而是直接选择 leader 测过的结果
|
||||
*
|
||||
* 5. leader target 指定了某个源
|
||||
* 5. leader target 测速出来的某个源
|
||||
*
|
||||
* @dependency 已存在的局部变量 @var:option
|
||||
*/
|
||||
#define chsrc_yield_for_the_source(for_what) \
|
||||
#define chsrc_yield_source(for_what) \
|
||||
Source_t source; \
|
||||
if (chsrc_in_target_group_mode() && TargetGroupMode.leader_selected_index==-1) \
|
||||
{ \
|
||||
TargetGroupMode.leader_selected_index = use_specific_mirror_or_auto_select (option, for_what); \
|
||||
@ -882,9 +885,6 @@ source_has_empty_url (Source_t *source)
|
||||
source = for_what##_sources[__index]; \
|
||||
}
|
||||
|
||||
#define chsrc_yield_source(for_what) \
|
||||
Source_t source; \
|
||||
chsrc_yield_for_the_source(for_what)
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Contributors : Mr. Will <mr.will.com@outlook.com>
|
||||
* Created On : <2023-09-09>
|
||||
* Major Reviison : 3
|
||||
* Last Modified : <2024-09-13>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
static double
|
||||
@ -40,9 +40,8 @@ pl_nodejs_yarn_getsrc (char *option)
|
||||
void
|
||||
pl_nodejs_yarn_setsrc (char *option)
|
||||
{
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_nodejs);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_nodejs);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *cmd = NULL;
|
||||
@ -71,7 +70,7 @@ pl_nodejs_yarn_setsrc (char *option)
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
}
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Contributors : Mr. Will <mr.will.com@outlook.com>
|
||||
* Created On : <2023-08-30>
|
||||
* Major Revision : 2
|
||||
* Last Modified : <2024-09-13>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -26,9 +26,8 @@ pl_nodejs_npm_getsrc (char *option)
|
||||
void
|
||||
pl_nodejs_npm_setsrc (char *option)
|
||||
{
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_nodejs);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_nodejs);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *cmd = NULL;
|
||||
@ -40,7 +39,7 @@ pl_nodejs_npm_setsrc (char *option)
|
||||
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Contributors : Nul None <nul@none.org>
|
||||
* Created On : <2024-04-18>
|
||||
* Major Revision : 2
|
||||
* Last Modified : <2024-09-13>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -27,9 +27,8 @@ pl_nodejs_pnpm_getsrc (char *option)
|
||||
void
|
||||
pl_nodejs_pnpm_setsrc (char *option)
|
||||
{
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_nodejs);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_nodejs);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *cmd = NULL;
|
||||
@ -41,7 +40,7 @@ pl_nodejs_pnpm_setsrc (char *option)
|
||||
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nul None <nul@none.org>
|
||||
* Created On : <2024-06-05>
|
||||
* Last Modified : <2024-09-14>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -28,9 +28,8 @@ pl_python_pdm_getsrc (char *option)
|
||||
void
|
||||
pl_python_pdm_setsrc (char *option)
|
||||
{
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_python);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_python);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *cmd = NULL;
|
||||
@ -42,7 +41,7 @@ pl_python_pdm_setsrc (char *option)
|
||||
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nil Null <nil@null.org>
|
||||
* Created On : <2024-08-08>
|
||||
* Last Modified : <2024-09-14>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
// @note Poetry 默认使用项目级换源
|
||||
@ -27,9 +27,8 @@ pl_python_poetry_getsrc (char *option)
|
||||
void
|
||||
pl_python_poetry_setsrc (char *option)
|
||||
{
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_python);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_python);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *cmd = NULL;
|
||||
@ -40,7 +39,7 @@ pl_python_poetry_setsrc (char *option)
|
||||
cmd = xy_2strjoin ("poetry source add my_mirror ", source.url);
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nul None <nul@none.org>
|
||||
* Created On : <2024-12-06>
|
||||
* Last Modified : <2024-12-06>
|
||||
* Last Modified : <2025-07-11>
|
||||
*
|
||||
* 由于Rye已经有后继uv了,所以我们不把该管理器纳入Python group中
|
||||
* ------------------------------------------------------------*/
|
||||
@ -38,6 +38,7 @@ pl_python_rye_getsrc (char *option)
|
||||
void
|
||||
pl_python_rye_setsrc (char *option)
|
||||
{
|
||||
/* 并不在 Python group 中,所以不考虑 target group 情况 */
|
||||
chsrc_yield_source_and_confirm (pl_python);
|
||||
|
||||
const char *file = xy_strjoin (7,
|
||||
|
@ -4,7 +4,7 @@
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Nul None <nul@none.org>
|
||||
* Created On : <2023-09-03>
|
||||
* Last Modified : <2024-09-14>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -38,9 +38,8 @@ pl_python_pip_setsrc (char *option)
|
||||
return;
|
||||
}
|
||||
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_python);
|
||||
if (!chsrc_in_target_group_mode())
|
||||
chsrc_yield_source (pl_python);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *py_prog_name = NULL;
|
||||
@ -52,7 +51,7 @@ pl_python_pip_setsrc (char *option)
|
||||
char *cmd = xy_2strjoin (py_prog_name, xy_2strjoin (" -m pip config --user set global.index-url ", source.url));
|
||||
chsrc_run (cmd, RunOpt_No_Last_New_Line);
|
||||
|
||||
if (!chsrc_in_target_group_mode())
|
||||
if (chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* | Aoran Zeng <ccmywish@qq.com>
|
||||
* |
|
||||
* Created On : <2024-12-11>
|
||||
* Last Modified : <2025-06-02>
|
||||
* Last Modified : <2025-07-11>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -94,10 +94,11 @@ pl_python_uv_getsrc (char *option)
|
||||
void
|
||||
pl_python_uv_setsrc (char *option)
|
||||
{
|
||||
chsrc_ensure_program("uv");
|
||||
chsrc_ensure_program ("uv");
|
||||
|
||||
Source_t source;
|
||||
chsrc_yield_for_the_source (pl_python);
|
||||
chsrc_yield_source (pl_python);
|
||||
if (chsrc_in_standalone_mode())
|
||||
chsrc_confirm_source;
|
||||
|
||||
char *uv_config = pl_python_find_uv_config (true);
|
||||
if (NULL==uv_config)
|
||||
@ -168,8 +169,12 @@ pl_python_uv_setsrc (char *option)
|
||||
chsrc_run (cmd, RunOpt_Default);
|
||||
}
|
||||
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
|
||||
if(chsrc_in_standalone_mode())
|
||||
{
|
||||
chsrc_determine_chgtype (ChgType_Auto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user