简体   繁体   English

使用提交的哈希安装 gem

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

I have really simple Gemfile :我有非常简单的Gemfile

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

When I run bundle command to install this gem I get this error:当我运行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?

But I can visit the commit's page on Github using this link https://github.com/mnin/stripe-ruby-mock/commit/b6446fb5ae2b14b6703554cbea4ebd466e4f3c47 .但我可以使用此链接https://github.com/mnin/stripe-ruby-mock/commit/b6446fb5ae2b14b6703554cbea4ebd466e4f3c47访问 Github 上的提交页面。

So how can I the gem using this commit's hash?那么我怎样才能使用这个提交的哈希值呢?

That commit is not reachable from any branch or tag.该提交无法从任何分支或标签访问。 For that reason, when you clone the repo from GitHub (which Bundler does under the hood), your local copy will not have that commit.出于这个原因,当您从 GitHub 克隆存储库(Bundler 在幕后进行)时,您的本地副本将不会进行该提交。

Thus, you can't use it.因此,您无法使用它。

On GitHub, you can see that this commit is not reachable as it doesn't list any branch or tag that contains it:在 GitHub 上,您可以看到此提交无法访问,因为它没有列出任何包含它的分支或标签:

在此处输入图片说明

Compare that to the parent commit, which lists as being reachable from master:将其与父提交进行比较,该提交被列为可从 master 访问:

在此处输入图片说明

Note that orphaned commits would get garbage collected by Git eventually.请注意,孤立的提交最终会被 Git 收集。 GitHub though doesn't do that as there might be references to particular commits. GitHub 并没有这样做,因为可能会有对特定提交的引用。

Try not to use forked gem if possible.如果可能,尽量不要使用分叉的 gem。 But if you need to lock a forked version, make sure you own the fork.但是,如果您需要锁定分叉版本,请确保您拥有该分叉。 Fork the forked branch, merge it to your own repo's main branch, and then just use that repo in your gemfile. Fork 分支,将其合并到您自己的 repo 的主分支,然后在您的 gemfile 中使用该 repo。

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

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