Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Github 如何在Cargo.toml的依赖项中指定特定的提交?_Github_Rust_Rust Cargo - Fatal编程技术网

Github 如何在Cargo.toml的依赖项中指定特定的提交?

Github 如何在Cargo.toml的依赖项中指定特定的提交?,github,rust,rust-cargo,Github,Rust,Rust Cargo,我正试图在GitHub中使用外部依赖项配置我的Rust项目。不幸的是,最近的一些提交对接口进行了一些更改,因此我无法使用最新版本。开发人员也不关心不同版本的标记和单独的分支,因此我认为唯一正确的方法是在接口适合我使用的地方指定特定的提交 我现在在Cargo.toml中看到的是: [dependencies] ... thelib = { git = 'https://github.com/someguys/thelib' } 我发现可以指定如下分支: thelib = { git = 'htt

我正试图在GitHub中使用外部依赖项配置我的Rust项目。不幸的是,最近的一些提交对接口进行了一些更改,因此我无法使用最新版本。开发人员也不关心不同版本的标记和单独的分支,因此我认为唯一正确的方法是在接口适合我使用的地方指定特定的提交

我现在在Cargo.toml中看到的是:

[dependencies]
...
thelib = { git = 'https://github.com/someguys/thelib' }
我发现可以指定如下分支:

thelib = { git = 'https://github.com/someguys/thelib', branch = 'branch1' }

但我还没有看到一个使用commit的工作示例。有人可以在这里提供吗?

您可以使用
rev
键指定提交散列。例如:

thelib = { git = "https://github.com/someguys/thelib", rev = "9f35b8e" }
正如《货物指南》一节中所暗示的,您可以使用
rev
属性指定提交散列:

[…]如果你今天构建这个包,然后你发送一个副本给我,我明天构建这个包,那么可能会发生一些不好的事情。在此期间,可能会有更多的提交给兰德,我的构建将包括新的提交,而你的构建不会。因此,我们将得到不同的构建。这将是不好的,因为我们需要可复制的构建

我们可以通过在我们的货物中放置一个rev行来解决此问题。toml:

[dependencies]
rand = { git = "https://github.com/rust-lang-nursery/rand.git", rev = "9f35b8e" }
虽然没有给出示例,但在中也提到了(我的重点):

由于我们没有指定任何其他信息,Cargo假设我们打算使用
master
分支上的最新提交来构建我们的包。您可以将git键与
rev
标记
、或
分支
键组合,以指定其他内容。[……]


但请注意,如果板条箱具有git依赖项,则不能发布板条箱。