Skip to content

Commit 2d75a48

Browse files
committed
Use chsrc_determine_chgtype()
1 parent 7226eec commit 2d75a48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+113
-85
lines changed

src/framework/core.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* | Yangmoooo <[email protected]>
1010
* |
1111
* Created On : <2023-08-29>
12-
* Last Modified : <2024-12-14>
12+
* Last Modified : <2025-03-06>
1313
*
1414
* chsrc framework
1515
* ------------------------------------------------------------*/
@@ -783,6 +783,11 @@ source_has_empty_url (Source_t *source)
783783
return source->url == NULL;
784784
}
785785

786+
bool
787+
is_reset_mode ()
788+
{
789+
return ProgMode_CMD_Reset;
790+
}
786791

787792

788793
/**
@@ -868,6 +873,13 @@ confirm_source (Source_t *source)
868873
#define chsrc_yield_source_and_confirm(for_what) chsrc_yield_source(for_what);chsrc_confirm_source
869874

870875

876+
void
877+
chsrc_determine_chgtype (enum ChgType_t type)
878+
{
879+
ProgMode_ChgType = is_reset_mode() ? ChgType_Reset : type;
880+
}
881+
882+
871883

872884
#define MSG_EN_PUBLIC_URL "If the URL you specify is a public service, you are invited to contribute: chsrc issue"
873885
#define MSG_CN_PUBLIC_URL "若您指定的URL为公有服务,邀您参与贡献: chsrc issue"
@@ -895,7 +907,7 @@ confirm_source (Source_t *source)
895907
/**
896908
* @param source 可为NULL
897909
*
898-
* @param[g] ProgMode_ChgType
910+
* @param [g]ProgMode_ChgType
899911
*/
900912
void
901913
chsrc_conclude (Source_t *source)

src/recipe/lang/Clojure.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ pl_clojure_setsrc (char *option)
2727

2828
chsrc_note2 ("抱歉,Clojure换源较复杂,您可手动查阅并换源:");
2929
p(source.url);
30-
ProgMode_ChgType = ChgType_Manual;
30+
31+
chsrc_determine_chgtype (ChgType_Manual);
3132
chsrc_conclude (&source);
3233
}
3334

src/recipe/lang/Dart/Flutter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pl_dart_flutter_setsrc (char *option)
8484
}
8585
}
8686

87-
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
87+
chsrc_determine_chgtype (ChgType_Auto);
8888
chsrc_conclude (&source);
8989
}
9090

src/recipe/lang/Dart/Pub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pl_dart_setsrc (char *option)
8080
}
8181
}
8282

83-
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
83+
chsrc_determine_chgtype (ChgType_Auto);
8484
chsrc_conclude (&source);
8585
}
8686

src/recipe/lang/Go.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ pl_go_setsrc (char *option)
8383

8484
cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct");
8585
chsrc_run (cmd, RunOpt_Default);
86-
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
86+
87+
chsrc_determine_chgtype (ChgType_Auto);
8788
chsrc_conclude (&source);
8889
}
8990

src/recipe/lang/Haskell.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ pl_haskell_setsrc (char *option)
6262

6363
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
6464
p(file);
65-
ProgMode_ChgType = ChgType_Manual;
65+
66+
chsrc_determine_chgtype (ChgType_Manual);
6667
chsrc_conclude (&source);
6768
}
6869

src/recipe/lang/Java.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ pl_java_setsrc (char *option)
101101
chsrc_note2 ("请在您的 build.gradle 中添加:");
102102
p(file);
103103
}
104-
ProgMode_ChgType = ChgType_Manual;
104+
105+
chsrc_determine_chgtype (ChgType_Manual);
105106
chsrc_conclude (&source);
106107
}
107108

src/recipe/lang/Julia.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pl_julia_setsrc (char *option)
4949

5050
chsrc_append_to_file (w, PL_Julia_Config);
5151

52-
ProgMode_ChgType = ChgType_Untested;
52+
chsrc_determine_chgtype (ChgType_Untested);
5353
chsrc_conclude (&source);
5454
}
5555

src/recipe/lang/Lua.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pl_lua_getsrc (char *option)
3434
}
3535

3636
/**
37-
* Lua 换源,参考:https://luarocks.cn/
37+
* @consult https://luarocks.cn/
3838
*/
3939
void
4040
pl_lua_setsrc (char *option)
@@ -54,7 +54,7 @@ pl_lua_setsrc (char *option)
5454
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");
5555
p(upload_config);
5656

57-
ProgMode_ChgType = ChgType_Manual;
57+
chsrc_determine_chgtype (ChgType_Manual);
5858
chsrc_conclude (&source);
5959
}
6060

src/recipe/lang/Node.js/Bun.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ pl_nodejs_bun_setsrc (char *option)
4343
}
4444

4545
p(file);
46-
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
46+
47+
chsrc_determine_chgtype (ChgType_Auto);
4748
chsrc_conclude (&source);
4849
}
4950

0 commit comments

Comments
 (0)