移除 chef_allow_local_mode()

This commit is contained in:
Aoran Zeng
2026-02-24 14:23:44 +08:00
parent 7a42d417fa
commit cac80d1e37
4 changed files with 27 additions and 50 deletions

View File

@@ -357,28 +357,6 @@ chef_set_os_scope (Target_t *target)
}
void
chef_allow_local_mode (Target_t *target, Capability_t cap, const char *explain_zh, const char *explain_en)
{
xy_cant_be_null (target);
target->cap_local = cap;
if (cap == FullyCan)
{
target->cap_local_explain = xy_strdup (CHINESE ? "完全支持项目级换源" : "Supports project-level source switching");
return;
}
if (cap == CanNot)
{
target->cap_local_explain = xy_strdup (CHINESE ? "无法进行项目级换源" : "Unable to perform project-level source switching");
return;
}
target->cap_local_explain = xy_strdup (CHINESE ? explain_zh : explain_en);
}
void
chef_allow_user_define (Target_t *target)

View File

@@ -98,23 +98,6 @@ static bool in_dry_run_mode(){return ProgMode.DryRunMode;}
*/
/**
* -local 的含义是启用 *项目级* 换源
*
* 每个 target 对 [-local] 的支持情况可使用 | chsrc ls <target> | 来查看
*
*
* 1. 默认不使用该选项时,含义是 *全局* 换源,
*
* 全局分为 (1)系统级 (2)用户级
*
* 大多数第三方配置软件往往默认进行的是 *用户级* 的配置。所以 chsrc 首先将尝试使用 *用户级* 配置
*
* 2. 若不存在 *用户级* 的配置chsrc 将采用 *系统级* 的配置
*
* 3. 最终效果本质由第三方软件决定,如 poetry 默认实现的就是项目级的换源
*/
typedef enum ChgType_t
{
ChgType_Auto,

View File

@@ -95,11 +95,33 @@ Source_t;
#define FeedByPrelude NULL
/* 换源的作用域 */
typedef enum Scope_t
/**
* 换源的作用域
*
* 在 chsrc v0.2.4.2 以前,我们一直使用的是 `-local` 这个选项,其含义是启用 *项目级* 换源
*
* 1. 默认不使用该选项时,含义是 *全局* 换源,
*
* 全局分为 (1)系统级 (2)用户级
*
* 大多数第三方配置软件往往默认进行的是 *用户级* 的配置。所以 chsrc 首先将尝试使用 *用户级* 配置
*
* 2. 若不存在 *用户级* 的配置chsrc 将采用 *系统级* 的配置
*
* 3. 最终效果本质由第三方软件决定,如 poetry 默认实现的就是项目级的换源
*
* 但是后来,我们认为非 -local 时的行为即默认时比较模糊所以我们现在清晰地把作用域指明出来总共有3种类型的作用
* 分别是 ProjectScope、UserScope 和 SystemScope分别对应项目级、用户级和系统级的换源配置
*
* 还有一个叫 DefaultScope 的作用域,它不是一种新类型,而只表示默认作用域,即根据实际情况最佳的作用域。
* chsrc 将根据该 target 的实际情况来选择最合适的作用域来进行换源配置。最好的情况下DefaultScope 是三者之一,
* 这也是这里设计的初衷。然而现在有些 recipe 的换源行为,会在某种 Scope 不能够成功时退而求其次地使用另一个 Scope
* 来进行换源配置,这时 DefaultScope 就无法用一种作用域单独描述。
*/
#define NumberOfScopeType 3
typedef enum Scope_t
{
DefaultScope, /* 默认作用域,即根据实际情况最佳的作用域 */
DefaultScope, /* 默认作用域,即根据实际情况最佳的作用域,它不是一种类型,只类似一个占位符 */
ProjectScope,
UserScope,
@@ -107,7 +129,6 @@ typedef enum Scope_t
}
Scope_t;
#define NumberOfScopeType 3
#define ScopeCap_Slot_Project 0
#define ScopeCap_Slot_User 1
#define ScopeCap_Slot_System 2
@@ -164,9 +185,6 @@ typedef struct Target_t
bool can_user_define; /* 是否支持用户自定义URL来换源 */
char *can_user_define_explain; /* 用户自定义URL的说明 */
Capability_t cap_local; /* 是否支持 local mode */
char *cap_local_explain; /* local mode 的说明 */
/**
* 各作用域的支持情况
* 参考 ScopeCap_Slot_Xxx 的值

View File

@@ -6,7 +6,7 @@
* Contributors : Mikachu2333 <mikachu.23333@zohomail.com>
* |
* Created On : <2024-08-09>
* Last Modified : <2026-02-22>
* Last Modified : <2026-02-24>
* -------------------------------------------------------------
* 本文件作为一个通用模板:
*
@@ -70,8 +70,6 @@ void
// 做了贡献?将自己的信息加在这里!
chef_set_sauciers (this, 2, "@nulnone", "@someone");
chef_allow_local_mode (this, PartiallyCan, "具体说明是否支持项目级换源...", "Tell users the local mode support");
chef_set_scope_cap (this, ProjectScope, ScopeCap_Able_And_Implemented);
chef_set_scope_cap (this, UserScope, ScopeCap_Able_But_NotImplemented);
chef_set_scope_cap (this, SystemScope, ScopeCap_Unable);