summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2026-05-07 19:11:54 +0900
committergit <svn-admin@ruby-lang.org>2026-05-08 06:43:43 +0000
commitf451ea9c9f8c5d11798cdd1ecf8f8865cd3654d2 (patch)
tree9eeb218b35276c289226fe487b8d07d67b2affc3
parent3a93bdcbbdd5b52877fa62205fc69f050848d8b8 (diff)
[ruby/rubygems] Capture Gemfile source location for each override
Bundler::Dsl#override now records caller_locations(1, 1).first on each Override so the originating Gemfile line can be surfaced in later diagnostics. https://github.com/ruby/rubygems/commit/ef73385cdc Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
-rw-r--r--lib/bundler/dsl.rb3
-rw-r--r--lib/bundler/override.rb10
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 46389b6c68..d67291514b 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -201,8 +201,9 @@ module Bundler
validate_override_uniqueness!(target, field)
end
+ source_location = caller_locations(1, 1)&.first
operations.each do |field, operation|
- @overrides << Override.new(target, field, operation)
+ @overrides << Override.new(target, field, operation, source_location: source_location)
end
end
diff --git a/lib/bundler/override.rb b/lib/bundler/override.rb
index ed5b51281f..7b71415290 100644
--- a/lib/bundler/override.rb
+++ b/lib/bundler/override.rb
@@ -9,12 +9,18 @@ module Bundler
overrides.find {|o| o.target == :all && o.field == field }
end
- attr_reader :target, :field, :operation
+ attr_reader :target, :field, :operation, :source_location
- def initialize(target, field, operation)
+ def initialize(target, field, operation, source_location: nil)
@target = target
@field = field
@operation = operation
+ @source_location = source_location
+ end
+
+ def source_location_label
+ return nil unless @source_location
+ "#{File.basename(@source_location.path)}:#{@source_location.lineno}"
end
def apply_to(requirement)