class method
Gem.source_date_epoch_string
() -> ::String
source_date_epoch_string
lib/rubygems.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems.rb, line 1216
def self.source_date_epoch_string
specified_epoch = ENV["SOURCE_DATE_EPOCH"]
# If it's empty or just whitespace, treat it like it wasn't set at all.
specified_epoch = nil if !specified_epoch.nil? && specified_epoch.strip.empty?
epoch = specified_epoch || DEFAULT_SOURCE_DATE_EPOCH.to_s
epoch.strip
end
If the SOURCE_DATE_EPOCH environment variable is set, returns it’s value. Otherwise, returns DEFAULT_SOURCE_DATE_EPOCH as a string.
NOTE(@duckinator): The implementation is a tad weird because we want to:
1. Make builds reproducible by default, by having this function always return the same result during a given run. 2. Allow changing ENV['SOURCE_DATE_EPOCH'] at runtime, since multiple tests that set this variable will be run in a single process.
If you simplify this function and a lot of tests fail, that is likely due to #2 above.
Details on SOURCE_DATE_EPOCH: reproducible-builds.org/specs/source-date-epoch/
See also
.source_date_epoch
.sources
.solaris_platform?
.sources=
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0