From b6ad8fd0ad5e92cdac84ee43affa20d3c2a0f9a6 Mon Sep 17 00:00:00 2001 From: Myron Marston Date: Tue, 31 Dec 2024 21:40:59 -0800 Subject: [PATCH] Fix `Gemfile` to be compatible with dependabot. My earlier attempts (e.g. #82) did not work. Using the `dry_run` script[^1], I've discovered that dependabot runs bundler commands in a temporary directory that only contains _some_ of the source controlled files (e.g. the `Gemfile`, `*.gemspec` files, etc). To be compatible with dependabot, our `Gemfile` cannot assume the presence of any files beyond these. [^1]: https://github.com/dependabot/dependabot-core/blob/v0.291.0/bin/dry-run.rb --- Gemfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index f3b57d16..e45952ae 100644 --- a/Gemfile +++ b/Gemfile @@ -39,8 +39,8 @@ group :site do end # Since this file gets symlinked both at the repo root and into each Gem directory, we have -# to dynamically detect the repo root, by looking for a file that only exists at the root. -repo_root = ::Pathname.new(::Dir.pwd).ascend.find { |dir| ::File.exist?("#{dir}/CODE_OF_CONDUCT.md") }.to_s +# to dynamically detect the repo root, by looking for one of the subdirs at the root. +repo_root = ::Pathname.new(__dir__).ascend.find { |dir| ::Dir.exist?("#{dir}/elasticgraph-support") }.to_s # `tmp` and `log` are git-ignored but many of our build tasks and scripts expect them to exist. # We create them here since `Gemfile` evaluation happens before anything else. @@ -48,8 +48,9 @@ repo_root = ::Pathname.new(::Dir.pwd).ascend.find { |dir| ::File.exist?("#{dir}/ ::FileUtils.mkdir_p("#{repo_root}/tmp") # Identify the gems that live in the ElasticGraph repository. -require "#{repo_root}/script/list_eg_gems" -gems_in_this_repo = ::ElasticGraphGems.list.to_set +gems_in_this_repo = ::Dir.glob("#{repo_root}/*/*.gemspec").map do |gemspec| + ::File.basename(::File.dirname(gemspec)) +end.to_set # Here we override the `gem` method to automatically add the ElasticGraph version # to all ElasticGraph gems. If we don't do this, we can get confusing bundler warnings