繁体   English   中英

使用提交的哈希安装 gem

[英]Installing a gem using a commit's hash

我有非常简单的Gemfile

source 'https://rubygems.org'                                                                                                                                                                                                                                                                                                                                                                                                   
gem 'stripe-ruby-mock', 
  github: 'mnin/stripe-ruby-mock', 
  require: 'stripe_mock', 
  ref: 'b6446fb5ae2b14b6703554cbea4ebd466e4f3c47'

当我运行bundle命令来安装这个 gem 时,我收到这个错误:

root@6bcff6bf3997:/app# bundle
The git source `git://github.com/mnin/stripe-ruby-mock.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Fetching git://github.com/mnin/stripe-ruby-mock.git
fatal: Could not parse object 'b6446fb5ae2b14b6703554cbea4ebd466e4f3c47'.
Revision b6446fb5ae2b14b6703554cbea4ebd466e4f3c47 does not exist in the repository git://github.com/mnin/stripe-ruby-mock.git. Maybe you misspelled it?

但我可以使用此链接https://github.com/mnin/stripe-ruby-mock/commit/b6446fb5ae2b14b6703554cbea4ebd466e4f3c47访问 Github 上的提交页面。

那么我怎样才能使用这个提交的哈希值呢?

该提交无法从任何分支或标签访问。 出于这个原因,当您从 GitHub 克隆存储库(Bundler 在幕后进行)时,您的本地副本将不会进行该提交。

因此,您无法使用它。

在 GitHub 上,您可以看到此提交无法访问,因为它没有列出任何包含它的分支或标签:

在此处输入图片说明

将其与父提交进行比较,该提交被列为可从 master 访问:

在此处输入图片说明

请注意,孤立的提交最终会被 Git 收集。 GitHub 并没有这样做,因为可能会有对特定提交的引用。

如果可能,尽量不要使用分叉的 gem。 但是,如果您需要锁定分叉版本,请确保您拥有该分叉。 Fork 分支,将其合并到您自己的 repo 的主分支,然后在您的 gemfile 中使用该 repo。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM