簡體   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