@huabuyu233/edgit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,407 @@
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other
34
+ CC-licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+
71
+ Section 1 -- Definitions.
72
+
73
+ a. Adapted Material means material subject to Copyright and Similar
74
+ Rights that is derived from or based upon the Licensed Material
75
+ and in which the Licensed Material is translated, altered,
76
+ arranged, transformed, or otherwise modified in a manner requiring
77
+ permission under the Copyright and Similar Rights held by the
78
+ Licensor. For purposes of this Public License, where the Licensed
79
+ Material is a musical work, performance, or sound recording,
80
+ Adapted Material is always produced where the Licensed Material is
81
+ synched in timed relation with a moving image.
82
+
83
+ b. Adapter's License means the license You apply to Your Copyright
84
+ and Similar Rights in Your contributions to Adapted Material in
85
+ accordance with the terms and conditions of this Public License.
86
+
87
+ c. Copyright and Similar Rights means copyright and/or similar rights
88
+ closely related to copyright including, without limitation,
89
+ performance, broadcast, sound recording, and Sui Generis Database
90
+ Rights, without regard to how the rights are labeled or
91
+ categorized. For purposes of this Public License, the rights
92
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
93
+ Rights.
94
+
95
+ d. Effective Technological Measures means those measures that, in the
96
+ absence of proper authority, may not be circumvented under laws
97
+ fulfilling obligations under Article 11 of the WIPO Copyright
98
+ Treaty adopted on December 20, 1996, and/or similar international
99
+ agreements.
100
+
101
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
102
+ any other exception or limitation to Copyright and Similar Rights
103
+ that applies to Your use of the Licensed Material.
104
+
105
+ f. Licensed Material means the artistic or literary work, database,
106
+ or other material to which the Licensor applied this Public
107
+ License.
108
+
109
+ g. Licensed Rights means the rights granted to You subject to the
110
+ terms and conditions of this Public License, which are limited to
111
+ all Copyright and Similar Rights that apply to Your use of the
112
+ Licensed Material and that the Licensor has authority to license.
113
+
114
+ h. Licensor means the individual(s) or entity(ies) granting rights
115
+ under this Public License.
116
+
117
+ i. NonCommercial means not primarily intended for or directed towards
118
+ commercial advantage or monetary compensation. For purposes of
119
+ this Public License, the exchange of the Licensed Material for
120
+ other material subject to Copyright and Similar Rights by digital
121
+ file-sharing or similar means is NonCommercial provided there is
122
+ no payment of monetary compensation in connection with the
123
+ exchange.
124
+
125
+ j. Share means to provide material to the public by any means or
126
+ process that requires permission under the Licensed Rights, such
127
+ as reproduction, public display, public performance, distribution,
128
+ dissemination, communication, or importation, and to make material
129
+ available to the public including in ways that members of the
130
+ public may access the material from a place and at a time
131
+ individually chosen by them.
132
+
133
+ k. Sui Generis Database Rights means rights other than copyright
134
+ resulting from Directive 96/9/EC of the European Parliament and of
135
+ the Council of 11 March 1996 on the legal protection of databases,
136
+ as amended and/or succeeded, as well as other essentially
137
+ equivalent rights anywhere in the world.
138
+
139
+ l. You means the individual or entity exercising the Licensed Rights
140
+ under this Public License. Your has a corresponding meaning.
141
+
142
+
143
+ Section 2 -- Scope.
144
+
145
+ a. License grant.
146
+
147
+ 1. Subject to the terms and conditions of this Public License,
148
+ the Licensor hereby grants You a worldwide, royalty-free,
149
+ non-sublicensable, non-exclusive, irrevocable license to
150
+ exercise the Licensed Rights in the Licensed Material to:
151
+
152
+ a. reproduce and Share the Licensed Material, in whole or
153
+ in part, for NonCommercial purposes only; and
154
+
155
+ b. produce, reproduce, and Share Adapted Material for
156
+ NonCommercial purposes only.
157
+
158
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
159
+ Exceptions and Limitations apply to Your use, this Public
160
+ License does not apply, and You do not need to comply with
161
+ its terms and conditions.
162
+
163
+ 3. Term. The term of this Public License is specified in Section
164
+ 6(a).
165
+
166
+ 4. Media and formats; technical modifications allowed. The
167
+ Licensor authorizes You to exercise the Licensed Rights in
168
+ all media and formats whether now known or hereafter created,
169
+ and to make technical modifications necessary to do so. The
170
+ Licensor waives and/or agrees not to assert any right or
171
+ authority to forbid You from making technical modifications
172
+ necessary to exercise the Licensed Rights, including
173
+ technical modifications necessary to circumvent Effective
174
+ Technological Measures. For purposes of this Public License,
175
+ simply making modifications authorized by this Section
176
+ 2(a)(4) never produces Adapted Material.
177
+
178
+ 5. Downstream recipients.
179
+
180
+ a. Offer from the Licensor -- Licensed Material. Every
181
+ recipient of the Licensed Material automatically
182
+ receives an offer from the Licensor to exercise the
183
+ Licensed Rights under the terms and conditions of this
184
+ Public License.
185
+
186
+ b. No downstream restrictions. You may not offer or impose
187
+ any additional or different terms or conditions on, or
188
+ apply any Effective Technological Measures to, the
189
+ Licensed Material if doing so restricts exercise of the
190
+ Licensed Rights by any recipient of the Licensed
191
+ Material.
192
+
193
+ 6. No endorsement. Nothing in this Public License constitutes or
194
+ may be construed as permission to assert or imply that You
195
+ are, or that Your use of the Licensed Material is, connected
196
+ with, or sponsored, endorsed, or granted official status by,
197
+ the Licensor or others designated to receive attribution as
198
+ provided in Section 3(a)(1)(A)(i).
199
+
200
+ b. Other rights.
201
+
202
+ 1. Moral rights, such as the right of integrity, are not
203
+ licensed under this Public License, nor are publicity,
204
+ privacy, and/or other similar personality rights; however, to
205
+ the extent possible, the Licensor waives and/or agrees not to
206
+ assert any such rights held by the Licensor to the limited
207
+ extent necessary to allow You to exercise the Licensed
208
+ Rights, but not otherwise.
209
+
210
+ 2. Patent and trademark rights are not licensed under this
211
+ Public License.
212
+
213
+ 3. To the extent possible, the Licensor waives any right to
214
+ collect royalties from You for the exercise of the Licensed
215
+ Rights, whether directly or through a collecting society
216
+ under any voluntary or waivable statutory or compulsory
217
+ licensing scheme. In all other cases the Licensor expressly
218
+ reserves any right to collect such royalties, including when
219
+ the Licensed Material is used other than for NonCommercial
220
+ purposes.
221
+
222
+
223
+ Section 3 -- License Conditions.
224
+
225
+ Your exercise of the Licensed Rights is expressly made subject to the
226
+ following conditions.
227
+
228
+ a. Attribution.
229
+
230
+ 1. If You Share the Licensed Material (including in modified
231
+ form), You must:
232
+
233
+ a. retain the following if it is supplied by the Licensor
234
+ with the Licensed Material:
235
+
236
+ i. identification of the creator(s) of the Licensed
237
+ Material and any others designated to receive
238
+ attribution, in any reasonable manner requested by
239
+ the Licensor (including by pseudonym if
240
+ designated);
241
+
242
+ ii. a copyright notice;
243
+
244
+ iii. a notice that refers to this Public License;
245
+
246
+ iv. a notice that refers to the disclaimer of
247
+ warranties;
248
+
249
+ v. a URI or hyperlink to the Licensed Material to the
250
+ extent reasonably practicable;
251
+
252
+ b. indicate if You modified the Licensed Material and
253
+ retain an indication of any previous modifications; and
254
+
255
+ c. indicate the Licensed Material is licensed under this
256
+ Public License, and include the text of, or the URI or
257
+ hyperlink to, this Public License.
258
+
259
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
260
+ reasonable manner based on the medium, means, and context in
261
+ which You Share the Licensed Material. For example, it may be
262
+ reasonable to satisfy the conditions by providing a URI or
263
+ hyperlink to a resource that includes the required
264
+ information.
265
+
266
+ 3. If requested by the Licensor, You must remove any of the
267
+ information required by Section 3(a)(1)(A) to the extent
268
+ reasonably practicable.
269
+
270
+ 4. If You Share Adapted Material You produce, the Adapter's
271
+ License You apply must not prevent recipients of the Adapted
272
+ Material from complying with this Public License.
273
+
274
+
275
+ Section 4 -- Sui Generis Database Rights.
276
+
277
+ Where the Licensed Rights include Sui Generis Database Rights that
278
+ apply to Your use of the Licensed Material:
279
+
280
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
281
+ to extract, reuse, reproduce, and Share all or a substantial
282
+ portion of the contents of the database for NonCommercial purposes
283
+ only;
284
+
285
+ b. if You include all or a substantial portion of the database
286
+ contents in a database in which You have Sui Generis Database
287
+ Rights, then the database in which You have Sui Generis Database
288
+ Rights (but not its individual contents) is Adapted Material; and
289
+
290
+ c. You must comply with the conditions in Section 3(a) if You Share
291
+ all or a substantial portion of the contents of the database.
292
+
293
+ For the avoidance of doubt, this Section 4 supplements and does not
294
+ replace Your obligations under this Public License where the Licensed
295
+ Rights include other Copyright and Similar Rights.
296
+
297
+
298
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
299
+
300
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
301
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
302
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
303
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
304
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
305
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
306
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
307
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
308
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
309
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
310
+
311
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
312
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
313
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
314
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
315
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
316
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
317
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
318
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
319
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
320
+
321
+ c. The disclaimer of warranties and limitation of liability provided
322
+ above shall be interpreted in a manner that, to the extent
323
+ possible, most closely approximates an absolute disclaimer and
324
+ waiver of all liability.
325
+
326
+
327
+ Section 6 -- Term and Termination.
328
+
329
+ a. This Public License applies for the term of the Copyright and
330
+ Similar Rights licensed here. However, if You fail to comply with
331
+ this Public License, then Your rights under this Public License
332
+ terminate automatically.
333
+
334
+ b. Where Your right to use the Licensed Material has terminated under
335
+ Section 6(a), it reinstates:
336
+
337
+ 1. automatically as of the date the violation is cured, provided
338
+ it is cured within 30 days of Your discovery of the
339
+ violation; or
340
+
341
+ 2. upon express reinstatement by the Licensor.
342
+
343
+ For the avoidance of doubt, this Section 6(b) does not affect any
344
+ right the Licensor may have to seek remedies for Your violations
345
+ of this Public License.
346
+
347
+ c. For the avoidance of doubt, the Licensor may also offer the
348
+ Licensed Material under separate terms or conditions or stop
349
+ distributing the Licensed Material at any time; however, doing so
350
+ will not terminate this Public License.
351
+
352
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
353
+ License.
354
+
355
+
356
+ Section 7 -- Other Terms and Conditions.
357
+
358
+ a. The Licensor shall not be bound by any additional or different
359
+ terms or conditions communicated by You unless expressly agreed.
360
+
361
+ b. Any arrangements, understandings, or agreements regarding the
362
+ Licensed Material not stated herein are separate from and
363
+ independent of the terms and conditions of this Public License.
364
+
365
+
366
+ Section 8 -- Interpretation.
367
+
368
+ a. For the avoidance of doubt, this Public License does not, and
369
+ shall not be interpreted to, reduce, limit, restrict, or impose
370
+ conditions on any use of the Licensed Material that could lawfully
371
+ be made without permission under this Public License.
372
+
373
+ b. To the extent possible, if any provision of this Public License is
374
+ deemed unenforceable, it shall be automatically reformed to the
375
+ minimum extent necessary to make it enforceable. If the provision
376
+ cannot be reformed, it shall be severed from this Public License
377
+ without affecting the enforceability of the remaining terms and
378
+ conditions.
379
+
380
+ c. No term or condition of this Public License will be waived and no
381
+ failure to comply consented to unless expressly agreed to by the
382
+ Licensor.
383
+
384
+ d. Nothing in this Public License constitutes or may be interpreted
385
+ as a limitation upon, or waiver of, any privileges and immunities
386
+ that apply to the Licensor or You, including from the legal
387
+ processes of any jurisdiction or authority.
388
+
389
+ =======================================================================
390
+
391
+ Creative Commons Corporation ("Creative Commons") is not a party to its
392
+ public licenses. Notwithstanding, Creative Commons may elect to apply
393
+ one of its public licenses to material it publishes and in those
394
+ instances will be considered the "Licensor." The text of the Creative
395
+ Commons public licenses is dedicated to the public domain under the CC0
396
+ Public Domain Dedication. Except for the limited purpose of indicating
397
+ that material is shared under a Creative Commons public license or as
398
+ otherwise permitted by Creative Commons policies published at
399
+ creativecommons.org/policies, Creative Commons does not authorize the
400
+ use of the trademark "Creative Commons" or any other trademark or logo
401
+ of Creative Commons without its prior written consent including,
402
+ without limitation, in connection with any unauthorized modifications
403
+ to any of its public licenses or any other arrangements, understandings,
404
+ or agreements concerning use of licensed material. For the avoidance of
405
+ doubt, this paragraph does not form part of the public licenses.
406
+
407
+ Creative Commons may be contacted at creativecommons.org.
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # edgit
2
+
3
+ GitHub 仓库镜像加速克隆工具。一条命令,自动探测可用镜像站并加速 `git clone`,克隆完成后自动还原 remote,日常 `git pull` / `git push` 完全不受影响。
4
+
5
+ ```bash
6
+ edgit clone https://github.com/algerkong/AlgerMusicPlayer.git --depth 1
7
+ ```
8
+
9
+ ## 特性
10
+
11
+ - **镜像加速**:内置多个镜像站,按优先级并行探测「站点连通性 + 仓库可用性」,命中即从镜像克隆;全部未命中自动回落原始 GitHub 地址
12
+ - **对 git 零侵入**:不修改任何 git 配置(不使用 insteadOf),只有主动敲 `edgit` 才走镜像,日常 `git clone` / `git pull` 原样走 GitHub
13
+ - **remote 自动还原**:克隆完成后 `remote origin` 自动还原为原始 GitHub 地址,后续 pull / push 直连 GitHub
14
+ - **极速探测**:死站点 ~0.2s 淘汰(TCP 连通性预检,连不上不跑 git);镜像并行探测 + 3 秒宽限择优;命中结果缓存 10 分钟,期间克隆零探测
15
+ - **git 参数透传**:`--depth 1`、`-b main` 等参数原样传给 `git clone`
16
+ - **零依赖单文件**:纯 Go 标准库实现,无任何第三方依赖,下载一个可执行文件即可使用
17
+
18
+ ## 安装
19
+
20
+ 系统需已安装 git ≥ 2.x。推荐方式:下载对应平台发行包,运行 `init` 一键安装(自动改名、写入 PATH,装完即可直接使用 `edgit` 命令):
21
+
22
+ **Windows**(发行包 `edgit-windows-amd64.exe` / `edgit-windows-arm64.exe`):
23
+
24
+ ```powershell
25
+ .\edgit-windows-amd64.exe init
26
+ ```
27
+
28
+ 自动安装为 `%LOCALAPPDATA%\Programs\edgit\edgit.exe` 并加入用户级 PATH(重开终端生效)。
29
+
30
+ **Linux / macOS**(发行包 `edgit-linux-amd64` / `edgit-darwin-arm64` 等):
31
+
32
+ ```bash
33
+ chmod +x edgit-linux-amd64
34
+ ./edgit-linux-amd64 init
35
+ ```
36
+
37
+ 自动安装为 `~/.local/bin/edgit` 并补全 PATH(重开终端生效)。
38
+
39
+ **npm 安装**(同样提供 `edgit` 命令):
40
+
41
+ ```bash
42
+ npm install -g @huabuyu233/edgit
43
+ ```
44
+
45
+ 也可直接下载 Release 二进制手动放进 PATH 目录。验证安装:
46
+
47
+ ```bash
48
+ edgit version
49
+ ```
50
+
51
+ ## 快速开始
52
+
53
+ 可选的初始化向导(展示镜像站、自动补 PATH、赞助信息;不运行也可直接使用):
54
+
55
+ ```bash
56
+ edgit init
57
+ ```
58
+
59
+ 镜像加速克隆,git 参数原样透传:
60
+
61
+ ```bash
62
+ edgit clone https://github.com/algerkong/AlgerMusicPlayer.git --depth 1
63
+ edgit clone https://github.com/xxx/yyy.git -b main
64
+ ```
65
+
66
+ SSH 地址同样支持:
67
+
68
+ ```bash
69
+ edgit clone git@github.com:xxx/yyy.git
70
+ ```
71
+
72
+ Release 附件下载加速(高校镜像优先):
73
+
74
+ ```bash
75
+ edgit get https://github.com/VSCodium/vscodium/releases/download/1.135.06055/VSCodium-1.135.06055-x64.exe
76
+ edgit get https://github.com/xxx/yyy/releases/download/v1.0/tool.zip out.zip # 指定输出文件名
77
+ ```
78
+
79
+ 非 github.com 地址自动透传给 `git clone`,不走镜像:
80
+
81
+ ```bash
82
+ edgit clone https://gitlab.com/xxx/yyy.git # 原样透传
83
+ ```
84
+
85
+ 克隆完成后验证 remote 已还原:
86
+
87
+ ```bash
88
+ git remote -v
89
+ # origin https://github.com/algerkong/AlgerMusicPlayer.git (fetch)
90
+ # origin https://github.com/algerkong/AlgerMusicPlayer.git (push)
91
+ ```
92
+
93
+ ## 镜像管理
94
+
95
+ ```bash
96
+ edgit mirrors list # 列出全部镜像
97
+ edgit mirrors add https://gh.example.com/ # 添加镜像(代理前缀型)
98
+ edgit mirrors add 'https://gh.example.com/{owner}/{repo}.git' # 或 URL 模板
99
+ edgit mirrors disable gh-proxy.com # 禁用
100
+ edgit mirrors enable gh-proxy.com # 启用
101
+ edgit mirrors remove gh-proxy.com # 删除
102
+ ```
103
+
104
+ 内置镜像按**权威性**排序(知名高校镜像在前,其次经久不衰、社区口碑好的镜像,全部可增删启停):
105
+
106
+ | 优先级 | 镜像 | clone | release | 说明 |
107
+ |---|---|---|---|---|
108
+ | 1 | TUNA(清华) | — | ✓ | 高校镜像,仅镜像 Release 文件 |
109
+ | 2 | USTC(中科大) | — | ✓ | 高校镜像,仅镜像 Release 文件 |
110
+ | 3 | gitclone.com | ✓ | — | 2015 年起专做 git clone 加速,口碑最老牌 |
111
+ | 4 | gh-proxy.com | ✓ | ✓ | hunshcn/gh-proxy 开源项目官方站 |
112
+ | 5 | ghproxy.net | ✓ | ✓ | ghproxy 系老牌域名 |
113
+ | 6 | ghfast.top | ✓ | ✓ | 各验证清单长期收录 |
114
+ | 7 | moeyy.xyz | ✓ | ✓ | moeyy 开源项目公共服务 |
115
+ | 8 | gh.llkk.cc | ✓ | ✓ | 社区镜像 |
116
+
117
+ > 高校镜像(TUNA/USTC)只镜像 Release 文件和特定仓库,不支持任意仓库的 git clone,因此仅参与 Release 下载(`edgit get`);clone 按 1→3→8 中支持 clone 的镜像探测。镜像站列表会随时间失效,可通过 `mirrors add` / `remove` 自行维护。
118
+
119
+ ## 工作原理
120
+
121
+ ```
122
+ edgit clone <url> [git参数...]
123
+ 1. 解析 URL:github.com 的 HTTPS/SSH 走镜像;其他地址直接 git clone 透传
124
+ 2. 并行探测所有启用的镜像:
125
+ Stage 1 连通性预检 TCP 拨号镜像站:443(2~3s)→ 连不上立即淘汰,不跑 git
126
+ Stage 2 仓库探测 git ls-remote --symref <镜像URL> HEAD(8s)
127
+ 3. 优先级择优:选优先级最高的命中者;高优先级镜像慢/半死时,
128
+ 给 3 秒宽限期,超时即用已命中的镜像
129
+ 4. git clone <镜像URL> [参数] → git remote set-url origin <原GitHub地址>
130
+ 5. 全部未命中 → git clone <原GitHub地址>
131
+ ```
132
+
133
+ 命中缓存:最近命中的镜像缓存 10 分钟(`~/.edgit/cache.json`),期间克隆直接使用、跳过探测;镜像被禁用或过期后自动失效。
134
+
135
+ ## 配置
136
+
137
+ - 配置文件:`~/.edgit/config.json`(首次 `init` 或 `mirrors add/remove/disable` 时生成,未生成时使用内置镜像)
138
+ - 命中缓存:`~/.edgit/cache.json`(自动管理,无需手动编辑)
139
+
140
+ ## 从源码构建
141
+
142
+ 需 Go ≥ 1.22,零第三方依赖:
143
+
144
+ ```bash
145
+ git clone <本仓库>
146
+ cd edgit
147
+ go build -o edgit.exe ./src # Windows
148
+ go build -o edgit ./src # Linux / macOS
149
+ ```
150
+
151
+ 源码按模块组织在 `src/`(main.go 命令分发 / mirror.go 镜像表 / git.go git 封装 / release.go Release 下载 / config.go 配置 / init.go 初始化向导)。
152
+
153
+ 交叉编译全部平台:
154
+
155
+ ```bash
156
+ GOOS=linux GOARCH=amd64 go build -ldflags '-s -w' -o dist/edgit-linux-amd64 ./src
157
+ GOOS=darwin GOARCH=arm64 go build -ldflags '-s -w' -o dist/edgit-darwin-arm64 ./src
158
+ # ... 其余同理
159
+ ```
160
+
161
+ ## 许可证
162
+
163
+ 本项目采用 **CC BY-NC 4.0(署名-非商业)** 标准许可证(全文见 [LICENSE](LICENSE)):
164
+
165
+ - ✅ 个人/非商业用途自由使用、修改、分发(源码或二进制)
166
+ - ⚠️ 须署名原作者,注明修改,标注本许可证
167
+ - 🚫 **商业使用须事先取得作者书面授权**(NC 条款禁止商业使用,商用请通过项目仓库联系作者获取单独授权,类似 Qt/MySQL 双许可模式)
168
+
169
+ 完整条款以 [LICENSE](LICENSE) 中的英文原文为准。
170
+
171
+ ## 常见问题
172
+
173
+ **克隆很慢?** 首次克隆需探测镜像(并行,通常几秒内);命中后 10 分钟内克隆零探测。也可用 `mirrors disable` 关掉慢镜像调整优先级。
174
+
175
+ **某个镜像站挂了?** `edgit mirrors disable <id>` 禁用,或 `remove` 后 `add` 新镜像站。
176
+
177
+ **影响我平时用 git 吗?** 不影响。edgit 不修改 git 配置,只有主动调用 `edgit` 命令才生效。
178
+
179
+ **克隆后 push 会推到镜像站吗?** 不会。remote 已自动还原为 GitHub 地址。
package/bin/edgit.js ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('child_process');
5
+ const path = require('path');
6
+ const fs = require('fs');
7
+
8
+ const binaries = {
9
+ 'win32-x64': 'edgit-windows-amd64.exe',
10
+ 'win32-arm64': 'edgit-windows-arm64.exe',
11
+ 'darwin-x64': 'edgit-darwin-amd64',
12
+ 'darwin-arm64': 'edgit-darwin-arm64',
13
+ 'linux-x64': 'edgit-linux-amd64',
14
+ 'linux-arm64': 'edgit-linux-arm64',
15
+ };
16
+
17
+ const key = process.platform + '-' + process.arch;
18
+ const name = binaries[key];
19
+ if (!name) {
20
+ console.error('edgit: 不支持的平台 ' + key + ',请从 GitHub Releases 直接下载二进制');
21
+ process.exit(1);
22
+ }
23
+
24
+ const binPath = path.join(__dirname, '..', 'dist', name);
25
+ if (!fs.existsSync(binPath)) {
26
+ console.error('edgit: 未找到可执行文件 ' + binPath + ',请重新安装 npm 包');
27
+ process.exit(1);
28
+ }
29
+
30
+ if (process.platform !== 'win32') {
31
+ try { fs.chmodSync(binPath, 0o755); } catch (e) { /* 忽略 */ }
32
+ }
33
+
34
+ const r = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
35
+ if (r.error) {
36
+ console.error('edgit: ' + r.error.message);
37
+ process.exit(1);
38
+ }
39
+ process.exit(r.status === null ? 1 : r.status);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@huabuyu233/edgit",
3
+ "version": "0.2.0",
4
+ "description": "GitHub 仓库镜像加速克隆工具 —— 镜像加速 git clone 与 Release 下载,探测命中后自动还原 remote,对 git 零侵入",
5
+ "keywords": [
6
+ "git",
7
+ "github",
8
+ "clone",
9
+ "mirror",
10
+ "proxy",
11
+ "accelerator",
12
+ "镜像",
13
+ "加速",
14
+ "download",
15
+ "release"
16
+ ],
17
+ "author": "huabuyu233",
18
+ "license": "CC-BY-NC-4.0",
19
+ "homepage": "https://github.com/huabuyu233/edgit#readme",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/huabuyu233/edgit.git"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/huabuyu233/edgit/issues"
26
+ },
27
+ "bin": {
28
+ "edgit": "bin/edgit.js"
29
+ },
30
+ "files": [
31
+ "bin/",
32
+ "dist/",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "engines": {
37
+ "node": ">=10"
38
+ },
39
+ "os": [
40
+ "win32",
41
+ "darwin",
42
+ "linux"
43
+ ],
44
+ "cpu": [
45
+ "x64",
46
+ "arm64"
47
+ ]
48
+ }