3 个稳定版本
1.4.0 | 2024年6月15日 |
---|---|
1.3.1 | 2024年6月9日 |
1.3.0 | 2024年6月8日 |
176 在 开发工具 中排名
每月下载量 26 次
31KB
610 行
git-wire
A git 子命令,以声明方式将其他仓库的源代码部分连接到仓库中。
说明
-
如果您的环境中已安装 Rust
$ cargo install git-wire
或者您可以克隆 此仓库 来从源代码构建。
-
其他情况
目前不支持。
准备
在仓库根目录创建一个名为 .gitwire
的文件,格式如下 JSON。
[
{
"url": "url-of-the-repository",
"rev": "revision (commit hash or branch name or tag name)",
"src": "source directory of the target repository",
"dst": "directory where to put the `src` on this repositry"
},
...
]
name: 识别项目的可选键
您可以定义 "name"
作为识别项目的键。
它可以用来将命令的范围缩小到特定项目。
[
{
"name": "any string can be a name, it must be unique within a .gitwire file",
"url": "url-of-the-repository",
"rev": "revision (commit hash or branch name or tag name)",
"src": "source directory of the target repository",
"dst": "directory where to put the `src` on this repositry"
},
...
]
dsc: 描述项目的可选键
您可以定义 "dsc"
来描述项目。
[
{
"dsc": "a description of the item can be written here if you want",
"url": "url-of-the-repository",
"rev": "revision (commit hash or branch name or tag name)",
"src": "source directory of the target repository",
"dst": "directory where to put the `src` on this repositry"
},
...
]
mtd: 指定检出方法的可选键
您可以选择方法,例如 "shallow"
、"shallow_no_sparse"
和 "partial"
,如下检出 src。
[
{
"url": "url-of-the-repository",
"rev": "revision (commit hash or branch name or tag name)",
"src": "source directory of the target repository",
"dst": "directory where to put the `src` on this repositry",
"mtd": "shallow/shallow_no_sparse/partial"
},
...
]
关于检出方法
shallow (默认)
此方法一次从指定的 src
获取所有文件。在几乎所有情况下,它将是最佳选择。
如果您省略 "mtd"
键,则将自动使用 "shallow"
方法。
shallow_no_sparse
"shallow_no_sparse"
会一次性从指定的 rev
获取由该仓库管理的所有文件,它本质上比 "shallow"
和 "partial"
需要更多的内存和临时存储,但如果需要同步大量文件,它必须比 "partial"
快。
(它不应该比 "shallow"
快。)
我假设这是在使用 "shallow"
遇到问题时的一种替代方法。
部分(不推荐)
"partial"
逐个获取指定目录下的所有文件。由于它为每个文件分别执行下载(这是 git 命令的行为),随着文件数量的增加可能会变得非常慢。(在最坏的情况下,你可能会遇到错误)
有可能它在内存消耗方面优于 "shallow"
。但基本上似乎没有使用这种方法的动力。
命令
sync
根据 .gitwire
的定义同步依赖的源。
请注意,对于每个项目,在同步开始之前,它总是会清除目标。
$ git wire sync
check
根据 .gitwire
的定义检查源。
如果有差异,此命令将报告每个差异,并返回退出代码 1,否则返回 0。
$ git wire check
选项
name
-n <name>
或 --name <name>
可以用于同步和检查命令。
添加此选项后,命令将仅针对具有指定名称的项目执行。
target
-t <name>
或 --target <name>
可以用于同步和检查命令。
此选项是 --name
和 -n
的别名。
singlethread
如果你设置了这个选项,-s
或 --singlethread
,命令将使用单个线程工作。
除非你指定此选项,否则命令将使用多线程。
一个 .gitwire 的示例
此 .gitwire
示例将此仓库的 src/common
在修订版 v1.0.0 和 v1.1.0 中分别连接到 src_common_v1.0.0
,src_common_v1.1.0
目录。
https://github.com/msr1k/git-wire/blob/main/.gitwire
变更日志
-
v1.4.0 (2024/06/15)
- 使命令执行多线程化。
-s
,添加了--singlethread
选项,强制以单线程执行命令。-t
,添加了与现有-n
和--name
相同的--target
选项。
-
v1.3.1 (2024/06/09)
- 对文档和输出进行了增强。 (README、
--help
和控制台输出格式) - 支持彩色输出。
- 对文档和输出进行了增强。 (README、
-
v1.3.0 (2024/06/08)
将可选的
name
和dsc
键添加到.gitwire json对象中。name
可以用于缩小命令的作用范围。dsc
可以用来描述项目
-
v1.2.1 (2024/03/19)
更新了依赖的crates,没有包含功能更改。
-
v1.2.0 (2023/09/22)
将sparse-checkout功能添加到
"shallow"
检出方法中。在大多数情况下,它在内存和时间消耗方面都是最佳选择。并且之前的
"shallow"
检出方法重命名为"shallow_no_sparse"
,如果在使用"shallow"
时遇到问题,它可以作为一个替代方案。此外,还进行了一些小的改进。
-
v1.1.3 (2023/09/21)
修复:如果目标仓库位于包含
.git
的某处,则git wire check
错误地忽略了这个仓库中的所有文件,并且如果存在,则没有检测到任何更改。 -
v1.1.2
更新所有依赖crates的版本。
修复一个错别字。 -
v1.1.1
将默认检出方法从
"partial"
更改为"shallow"
,因为在大多数情况下,"shallow"
似乎更快且更稳定。 -
v1.1.0
添加了可选的
"mtd"
(方法)设置,可以控制检出目标源代码的方式。 -
v1.0.1
用另一个crates替换了一个依赖项,以减少不必要的依赖。
(从v1.0.0开始没有进行任何功能更改。) -
v1.0.0
初始版本。
许可协议
MIT许可协议
依赖项
~4–13MB
~148K SLoC