Ruby-on-rails 如何在协作上下文中处理打包器更新(Gemfile.lock)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14471109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:18:54  来源:igfitidea点击:

How to deal with bundler updates (Gemfile.lock) in collaborative context?

ruby-on-railsversion-controlbundlercollaborationgemfile

提问by user664833

I have been a lone programmer on a particular project, but now someone else has joined as collaborator. With just me in the picture, bundlerupdates have been smooth, and I never thought twice about Gemfile.lockbeing tracked by Git.

我一直是一个特定项目的孤独程序员,但现在其他人作为合作者加入了。只有我在图片中,bundler更新一直很顺利,我从来没有想过Gemfile.lock被 Git 跟踪。

The new collaborator ran bundle installafter cloning the repo, and Gemfile.lockwas updated as follows:

新的合作者bundle install在克隆 repo 后运行,并Gemfile.lock更新如下:

Gemfile.lock

Gemfile.lock

@@ -141,7 +141,7 @@ GEM
       rack-ssl (~> 1.3.2)
       rake (>= 0.8.7)
       rdoc (~> 3.4)
-      thor (< 2.0, >= 0.14.6)
+      thor (>= 0.14.6, < 2.0)
     raindrops (0.10.0)
     rake (0.9.2.2)
     rdoc (3.12)
@@ -164,7 +164,7 @@ GEM
     sprockets (2.1.3)
       hike (~> 1.2)
       rack (~> 1.0)
-      tilt (!= 1.3.0, ~> 1.1)
+      tilt (~> 1.1, != 1.3.0)
     thor (0.16.0)
     tilt (1.3.3)
     treetop (1.4.10)
@@ -175,7 +175,7 @@ GEM
     tzinfo (0.3.33)
     uglifier (1.3.0)
       execjs (>= 0.3.0)
-      multi_json (>= 1.0.2, ~> 1.0)
+      multi_json (~> 1.0, >= 1.0.2)
     unicorn (4.3.1)
       kgio (~> 2.6)
       rack

This change was pushed into a named branch off master. How am I supposed to deal with this change?

此更改被推送到 master 的命名分支中。我该如何应对这种变化?

Thinking out loud: Do I merge the Pull Request on GitHub? Do I just pull from upstream without a Pull Request at first? Do I run a particular bundler command to sync things up with the other collaborator's Gemfile.lock? Is there something the other collaborator could have done differently, so that they did not cause any gems to update (rather, just to download the gems specified in the existing Gemfile.lock)? What are the best practices around this situation?

大声思考:我是否在 GitHub 上合并 Pull Request?一开始我是否只是从上游拉取而没有拉取请求?我是否运行特定的 bundler 命令来与其他协作者的同步Gemfile.lock?是否有其他合作者可以做一些不同的事情,以便他们不会导致任何 gem 更新(相反,只是下载现有 中指定的 gem Gemfile.lock)?解决这种情况的最佳做法是什么?

回答by meagar

Gemfile.lock shouldbe version controlled. You should be committing any changes to it. When somebody (who you trust) updates it, you should run bundle installto install the gems currently locked in Gemfile.lock.

Gemfile.lock应该是版本控制的。您应该对其进行任何更改。当有人(您信任的人)更新它时,您应该运行bundle install以安装当前锁定在 Gemfile.lock 中的 gem。

Just running bundle installwill not update an existing Gemfile.lock. To do so, you need to run bundle update.

只是运行bundle install不会更新现有的 Gemfile.lock。为此,您需要运行bundle update.

All that said, there are no actual changes to the versions in your Gemfile.lock. All that changed was the order of arguments for a few lines. You can safely merge those changes in or disregard them; the resulting Gemfile.lock will be (functionally) identical.

尽管如此,您的 Gemfile.lock 中的版本没有实际更改。改变的只是几行的参数顺序。您可以安全地合并或忽略这些更改;生成的 Gemfile.lock 将(功能上)相同。