Sed vender path for jh/Gemfile.lock before bundle install
发现
在同步 GitLab repo 的 script 中, 有这样的步骤 cp Gemfile.lock jh/
, 目的是让 JH 的 Gem 都沿用 Upstream 的版本.
最终的目的是让后续的 bundle install
从 jh/Gemfile.lock
(此时跟 Gemfile.lock
内容完全一致) 读取已经锁定的 Gem 版本, 并把 Gemfile.jh
中的增量的 Gem 也添加到 jh/Gemfile.lock
(此时是最终版本) 中. 然后再把最终版本 push 到 repo 中.
但是从实际的结果中发现了一条例外:
file | content |
---|---|
Gemfile.lock |
google-cloud-profiler-v2 (0.4.0) |
jh/Gemfile.lock |
google-cloud-profiler-v2 (0.5.0) |
原因
在 cp Gemfile.lock jh/
之后, 会有这样的差异:
PATH
- remote: ../vendor/gems/cloud_profiler_agent
+ remote: vendor/gems/cloud_profiler_agent
specs:
cloud_profiler_agent (0.0.1.pre)
google-cloud-profiler-v2 (~> 0.3)
@@ -56,41 +20,41 @@ PATH
stackprof (~> 0.2)
bundle install
会因为 path 不一致而对这样的 Gem 重新解决依赖, 从而导致 lock 中的依赖版本被忽略.
完整的diff
diff --git a/jh/Gemfile.lock b/jh/Gemfile.lock
index f40830d67a54..f074a37cc8ed 100644
--- a/jh/Gemfile.lock
+++ b/jh/Gemfile.lock
@@ -1,53 +1,17 @@
-GIT
- remote: https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
- revision: a02d46963a57b0d48ef112e3fba208e911de9be9
- tag: 1.0.200
- glob: tencentcloud-sdk-captcha/tencentcloud-sdk-captcha.gemspec
- specs:
- tencentcloud-sdk-captcha (1.0.200)
- tencentcloud-sdk-common (~> 1.0)
-
-GIT
- remote: https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
- revision: a02d46963a57b0d48ef112e3fba208e911de9be9
- tag: 1.0.200
- glob: tencentcloud-sdk-common/tencentcloud-sdk-common.gemspec
- specs:
- tencentcloud-sdk-common (1.0.200)
-
-GIT
- remote: https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
- revision: a02d46963a57b0d48ef112e3fba208e911de9be9
- tag: 1.0.200
- glob: tencentcloud-sdk-sms/tencentcloud-sdk-sms.gemspec
- specs:
- tencentcloud-sdk-sms (1.0.200)
- tencentcloud-sdk-common (~> 1.0)
-
-GIT
- remote: https://jihulab.com/gitlab-cn/ruby/gems/gitlab-dangerfiles-jh.git
- revision: 4caaedcbf69a95efa82b54085824b29d3bb197aa
- tag: v3.6.6-jh
- specs:
- gitlab-dangerfiles-jh (3.6.6.pre.jh)
- danger (>= 8.4.5)
- danger-gitlab (>= 8.0.0)
- rake
-
PATH
- remote: ../vendor/gems/attr_encrypted
+ remote: vendor/gems/attr_encrypted
specs:
attr_encrypted (3.2.4)
encryptor (~> 3.0.0)
PATH
- remote: ../vendor/gems/bundler-checksum
+ remote: vendor/gems/bundler-checksum
specs:
bundler-checksum (0.1.0)
bundler
PATH
- remote: ../vendor/gems/cloud_profiler_agent
+ remote: vendor/gems/cloud_profiler_agent
specs:
cloud_profiler_agent (0.0.1.pre)
google-cloud-profiler-v2 (~> 0.3)
@@ -56,41 +20,41 @@ PATH
stackprof (~> 0.2)
PATH
- remote: ../vendor/gems/devise-pbkdf2-encryptable
+ remote: vendor/gems/devise-pbkdf2-encryptable
specs:
devise-pbkdf2-encryptable (0.0.0)
devise (~> 4.0)
devise-two-factor (~> 4.0)
PATH
- remote: ../vendor/gems/error_tracking_open_api
+ remote: vendor/gems/error_tracking_open_api
specs:
error_tracking_open_api (1.0.0)
typhoeus (~> 1.0, >= 1.0.1)
PATH
- remote: ../vendor/gems/ipynbdiff
+ remote: vendor/gems/ipynbdiff
specs:
ipynbdiff (0.4.7)
diffy (~> 3.4)
oj (~> 3.13.16)
PATH
- remote: ../vendor/gems/mail-smtp_pool
+ remote: vendor/gems/mail-smtp_pool
specs:
mail-smtp_pool (0.1.0)
connection_pool (~> 2.0)
mail (~> 2.7)
PATH
- remote: ../vendor/gems/microsoft_graph_mailer
+ remote: vendor/gems/microsoft_graph_mailer
specs:
microsoft_graph_mailer (0.1.0)
mail (~> 2.7)
oauth2 (>= 1.4.4, < 3)
PATH
- remote: ../vendor/gems/omniauth-azure-oauth2
+ remote: vendor/gems/omniauth-azure-oauth2
specs:
omniauth-azure-oauth2 (0.0.10)
jwt (>= 1.0, < 3.0)
@@ -98,7 +62,7 @@ PATH
omniauth-oauth2 (~> 1.4)
PATH
- remote: ../vendor/gems/omniauth-cas3
+ remote: vendor/gems/omniauth-cas3
specs:
omniauth-cas3 (1.1.4)
addressable (~> 2.3)
@@ -106,21 +70,21 @@ PATH
omniauth (~> 2.0)
PATH
- remote: ../vendor/gems/omniauth-gitlab
+ remote: vendor/gems/omniauth-gitlab
specs:
omniauth-gitlab (4.0.0)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.8)
PATH
- remote: ../vendor/gems/omniauth-salesforce
+ remote: vendor/gems/omniauth-salesforce
specs:
omniauth-salesforce (1.0.5)
omniauth (~> 2.0)
omniauth-oauth2 (~> 1.0)
PATH
- remote: ../vendor/gems/omniauth_crowd
+ remote: vendor/gems/omniauth_crowd
specs:
omniauth_crowd (2.4.0)
activesupport
@@ -128,7 +92,7 @@ PATH
omniauth (~> 2.0)
PATH
- remote: ../vendor/gems/sidekiq-reliable-fetch
+ remote: vendor/gems/sidekiq-reliable-fetch
specs:
gitlab-sidekiq-fetcher (0.9.0)
json (>= 2.5)
@@ -339,7 +303,6 @@ GEM
mixlib-shellout (>= 2.0, < 4.0)
tomlrb (~> 1.2)
chef-utils (16.10.17)
- chinese_pinyin (1.1.0)
chunky_png (1.3.5)
circuitbox (2.0.0.pre5)
citrus (3.0.2)
@@ -724,7 +687,7 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.0)
- google-cloud-profiler-v2 (0.5.0)
+ google-cloud-profiler-v2 (0.4.0)
gapic-common (>= 0.18.0, < 2.a)
google-cloud-errors (~> 1.0)
google-cloud-storage (1.44.0)
@@ -1179,8 +1142,6 @@ GEM
png_quantizator (0.2.1)
po_to_json (1.0.1)
json (>= 1.6.0)
- posthog-ruby (1.3.0)
- concurrent-ruby
premailer (1.16.0)
addressable
css_parser (>= 1.6.0)
@@ -1739,7 +1700,6 @@ DEPENDENCIES
capybara-screenshot (~> 1.0.26)
carrierwave (~> 1.3)
charlock_holmes (~> 0.7.7)
- chinese_pinyin
circuitbox (= 2.0.0.pre5)
cloud_profiler_agent (~> 0.0.0)!
commonmarker (~> 0.23.6)
@@ -1792,7 +1752,6 @@ DEPENDENCIES
gitaly (~> 15.9.0.pre.rc3)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 3.9.0)
- gitlab-dangerfiles-jh!
gitlab-experiment (~> 0.7.1)
gitlab-fog-azure-rm (~> 1.7.0)
gitlab-labkit (~> 0.31.1)
@@ -1911,7 +1870,6 @@ DEPENDENCIES
pg (~> 1.5.3)
pg_query (~> 2.2, >= 2.2.1)
png_quantizator (~> 0.2.1)
- posthog-ruby (~> 1.2, >= 1.2.4)
premailer-rails (~> 1.10.3)
prometheus-client-mmap (~> 0.23)
pry-byebug
@@ -1989,9 +1947,6 @@ DEPENDENCIES
sys-filesystem (~> 1.4.3)
tanuki_emoji (~> 0.6)
telesignenterprise (~> 2.2)
- tencentcloud-sdk-captcha!
- tencentcloud-sdk-common!
- tencentcloud-sdk-sms!
terser (= 1.0.2)
test-prof (~> 1.2.1)
test_file_finder (~> 0.1.3)
解决方案
在 bundle install
之前, 修改 Gem 的 Path ( 只针对基于 Path 方式安装的 Gem ), 让它们跟 jh 的路径匹配, 从而沿用 Gemfile.lock
中的依赖版本, 而不是从新处理依赖版本.
效果展示
Before
cbd@mbp16 gitlab % gs
On branch main-jh
Your branch is up to date with 'origin/main-jh'.
nothing to commit, working tree clean
cbd@mbp16 gitlab % cp Gemfile.lock jh/
cbd@mbp16 gitlab % bundle
Fetching https://jihulab.com/gitlab-cn/ruby/gems/gitlab-dangerfiles-jh.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Using rake 13.0.6
...
Installing lookbook 2.0.1
Installing devfile 0.0.17.pre.alpha1
Bundle complete! 316 Gemfile dependencies, 646 gems now installed.
Gems in the group 'production' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
2 installed gems you directly depend on are looking for funding.
Run `bundle fund` for details
cbd@mbp16 gitlab % gs
On branch main-jh
Your branch is up to date with 'origin/main-jh'.
nothing to commit, working tree clean
After
cbd@mbp16 gitlab % gs
On branch main-jh
Your branch is up to date with 'origin/main-jh'.
nothing to commit, working tree clean
cbd@mbp16 gitlab % cp Gemfile.lock jh/
cbd@mbp16 gitlab % sed -i 's@vendor@\.\.\/vendor@' jh/Gemfile.lock
cbd@mbp16 gitlab % bundle
Fetching https://jihulab.com/gitlab-cn/ruby/gems/gitlab-dangerfiles-jh.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching https://github.com/TencentCloud/tencentcloud-sdk-ruby.git
Fetching gem metadata from https://rubygems.org/.......
Resolving dependencies...
Using rake 13.0.6
...
Bundle complete! 316 Gemfile dependencies, 646 gems now installed.
Gems in the group 'production' were not installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
2 installed gems you directly depend on are looking for funding.
Run `bundle fund` for details
cbd@mbp16 gitlab % gs
On branch main-jh
Your branch is up to date with 'origin/main-jh'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: jh/Gemfile.lock
no changes added to commit (use "git add" and/or "git commit -a")
cbd@mbp16 gitlab % g diff
diff --git a/jh/Gemfile.lock b/jh/Gemfile.lock
index 92e0059186dd..3f7c94df045e 100644
--- a/jh/Gemfile.lock
+++ b/jh/Gemfile.lock
@@ -725,7 +725,7 @@ GEM
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.0)
- google-cloud-profiler-v2 (0.5.0)
+ google-cloud-profiler-v2 (0.4.0)
gapic-common (>= 0.18.0, < 2.a)
google-cloud-errors (~> 1.0)
google-cloud-storage (1.44.0)
由 Baodong 编辑于