Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package rubygem-dotenv for openSUSE:Factory checked in at 2026-07-15 16:33:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-dotenv (Old) and /work/SRC/openSUSE:Factory/.rubygem-dotenv.new.1991 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-dotenv" Wed Jul 15 16:33:49 2026 rev:2 rq:1365321 version:3.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-dotenv/rubygem-dotenv.changes 2024-12-11 21:10:22.884105655 +0100 +++ /work/SRC/openSUSE:Factory/.rubygem-dotenv.new.1991/rubygem-dotenv.changes 2026-07-15 16:49:55.243425692 +0200 @@ -1,0 +2,9 @@ +Mon Jul 13 09:04:16 UTC 2026 - Aleksei Burlakov <[email protected]> + +- Update to version 3.2.0: + * Boost app startup time by removing to_sentence usage by @ThomasCrambert + * Handle parentheses in variables in commands by @i7an + * allow warning when a env var was not overwritten by @grosser + * fix a few small issues by @grosser + +------------------------------------------------------------------- Old: ---- dotenv-3.1.4.gem New: ---- dotenv-3.2.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-dotenv.spec ++++++ --- /var/tmp/diff_new_pack.3WX7ST/_old 2026-07-15 16:49:59.783579954 +0200 +++ /var/tmp/diff_new_pack.3WX7ST/_new 2026-07-15 16:49:59.783579954 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-dotenv # -# Copyright (c) 2024 SUSE LLC +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,13 +24,13 @@ # Name: rubygem-dotenv -Version: 3.1.4 +Version: 3.2.0 Release: 0 %define mod_name dotenv %define mod_full_name %{mod_name}-%{version} -BuildRequires: ruby-macros >= 5 BuildRequires: %{ruby >= 3.0} BuildRequires: %{rubygem gem2rpm} +BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives URL: https://github.com/bkeepers/dotenv Source: https://rubygems.org/gems/%{mod_full_name}.gem ++++++ dotenv-3.1.4.gem -> dotenv-3.2.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2024-09-18 05:54:04.000000000 +0200 +++ new/README.md 1980-01-02 01:00:00.000000000 +0100 @@ -47,7 +47,10 @@ Dotenv.load ``` -By default, `load` will look for a file called `.env` in the current working directory. Pass in multiple files and they will be loaded in order. The first value set for a variable will win. +By default, `load` will look for a file called `.env` in the current working directory. +Pass in multiple files and they will be loaded in order. +The first value set for a variable will win. +Existing environment variables will not be overwritten unless you set `overwrite: true`. ```ruby require 'dotenv' @@ -84,7 +87,7 @@ $ dotenv ./script.rb ``` -The `dotenv` executable also accepts the flag `-f`. Its value should be a comma-separated list of configuration files, in the order of most important to least. All of the files must exist. There _must_ be a space between the flag and its value. +The `dotenv` executable also accepts the flag `-f`. Its value should be a comma-separated list of configuration files, in the order of the most important to the least important. All of the files must exist. There _must_ be a space between the flag and its value. ```console $ dotenv -f ".env.local,.env" ./script.rb @@ -213,7 +216,7 @@ ### Variable Substitution -You need to add the value of another variable in one of your variables? You can reference the variable with `${VAR}` or often just `$VAR` in unqoted or double-quoted values. +You need to add the value of another variable in one of your variables? You can reference the variable with `${VAR}` or often just `$VAR` in unquoted or double-quoted values. ```shell DATABASE_URL="postgres://${USER}@localhost/my_database" @@ -314,6 +317,9 @@ By default, it **won't** overwrite existing environment variables as dotenv assumes the deployment environment has more knowledge about configuration than the application does. To overwrite existing environment variables you can use `Dotenv.load files, overwrite: true`. +To warn when a value was not overwritten (e.g. to make users aware of this gotcha), +use `Dotenv.load files, overwrite: :warn`. + You can also use the `-o` or `--overwrite` flag on the dotenv cli to overwrite existing `ENV` variables. ```console Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/log_subscriber.rb new/lib/dotenv/log_subscriber.rb --- old/lib/dotenv/log_subscriber.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/log_subscriber.rb 1980-01-02 01:00:00.000000000 +0100 @@ -24,7 +24,7 @@ def update(event) diff = event.payload[:diff] changed = diff.env.keys.map { |key| color_var(key) } - debug "Set #{changed.to_sentence}" if diff.any? + debug "Set #{changed.join(", ")}" if diff.any? end def save(event) @@ -39,8 +39,8 @@ if removed.any? || restored.any? info "Restored snapshot of #{color_env_constant}" - debug "Unset #{removed.to_sentence}" if removed.any? - debug "Restored #{restored.to_sentence}" if restored.any? + debug "Unset #{removed.join(", ")}" if removed.any? + debug "Restored #{restored.join(", ")}" if restored.any? end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/missing_keys.rb new/lib/dotenv/missing_keys.rb --- old/lib/dotenv/missing_keys.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/missing_keys.rb 1980-01-02 01:00:00.000000000 +0100 @@ -3,7 +3,7 @@ class MissingKeys < Error # :nodoc: def initialize(keys) - key_word = "key#{(keys.size > 1) ? "s" : ""}" + key_word = "key#{"s" if keys.size > 1}" super("Missing required configuration #{key_word}: #{keys.inspect}") end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/parser.rb new/lib/dotenv/parser.rb --- old/lib/dotenv/parser.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/parser.rb 1980-01-02 01:00:00.000000000 +0100 @@ -8,27 +8,33 @@ # Parses the `.env` file format into key/value pairs. # It allows for variable substitutions, command substitutions, and exporting of variables. class Parser - @substitutions = - [Dotenv::Substitutions::Variable, Dotenv::Substitutions::Command] + @substitutions = [ + Dotenv::Substitutions::Command, + Dotenv::Substitutions::Variable + ] LINE = / - (?:^|\A) # beginning of line - \s* # leading whitespace - (?:export\s+)? # optional export - ([\w.]+) # key - (?:\s*=\s*?|:\s+?) # separator - ( # optional value begin - \s*'(?:\\'|[^'])*' # single quoted value - | # or - \s*"(?:\\"|[^"])*" # double quoted value - | # or - [^\#\r\n]+ # unquoted value - )? # value end - \s* # trailing whitespace - (?:\#.*)? # optional comment - (?:$|\z) # end of line + (?:^|\A) # beginning of line + \s* # leading whitespace + (?<export>export\s+)? # optional export + (?<key>[\w.]+) # key + (?: # optional separator and value + (?:\s*=\s*?|:\s+?) # separator + (?<value> # optional value begin + \s*'(?:\\'|[^'])*' # single quoted value + | # or + \s*"(?:\\"|[^"])*" # double quoted value + | # or + [^\#\n]+ # unquoted value + )? # value end + )? # separator and value end + \s* # trailing whitespace + (?:\#.*)? # optional comment + (?:$|\z) # end of line /x + QUOTED_STRING = /\A(['"])(.*)\1\z/m + class << self attr_reader :substitutions @@ -38,41 +44,54 @@ end def initialize(string, overwrite: false) - @string = string + # Convert line breaks to same format + @string = string.gsub(/\r\n?/, "\n") @hash = {} @overwrite = overwrite end def call - # Convert line breaks to same format - lines = @string.gsub(/\r\n?/, "\n") - # Process matches - lines.scan(LINE).each do |key, value| - @hash[key] = parse_value(value || "") - end - # Process non-matches - lines.gsub(LINE, "").split(/[\n\r]+/).each do |line| - parse_line(line) + @string.scan(LINE) do + match = $LAST_MATCH_INFO + + if existing?(match[:key]) + # Use value from already defined variable + @hash[match[:key]] = ENV[match[:key]] + elsif match[:export] && !match[:value] + # Check for exported variable with no value + if [email protected]?(match[:key]) + raise FormatError, "Line #{match.to_s.inspect} has an unset variable" + end + else + @hash[match[:key]] = parse_value(match[:value] || "") + end end + @hash end private - def parse_line(line) - if line.split.first == "export" - if variable_not_set?(line) - raise FormatError, "Line #{line.inspect} has an unset variable" - end - end + # Determine if a variable is already defined and should not be overwritten. + def existing?(key) + !@overwrite && key != "DOTENV_LINEBREAK_MODE" && ENV.key?(key) end def parse_value(value) # Remove surrounding quotes - value = value.strip.sub(/\A(['"])(.*)\1\z/m, '\2') + value = value.strip.sub(QUOTED_STRING, '\2') maybe_quote = Regexp.last_match(1) - value = unescape_value(value, maybe_quote) - perform_substitutions(value, maybe_quote) + + # Expand new lines in double quoted values + value = expand_newlines(value) if maybe_quote == '"' + + # Unescape characters and performs substitutions unless value is single quoted + if maybe_quote != "'" + value = unescape_characters(value) + self.class.substitutions.each { |proc| value = proc.call(value, @hash) } + end + + value end def unescape_characters(value) @@ -86,28 +105,5 @@ value.gsub('\n', "\\\\\\n").gsub('\r', "\\\\\\r") end end - - def variable_not_set?(line) - !line.split[1..].all? { |var| @hash.member?(var) } - end - - def unescape_value(value, maybe_quote) - if maybe_quote == '"' - unescape_characters(expand_newlines(value)) - elsif maybe_quote.nil? - unescape_characters(value) - else - value - end - end - - def perform_substitutions(value, maybe_quote) - if maybe_quote != "'" - self.class.substitutions.each do |proc| - value = proc.call(value, @hash, overwrite: @overwrite) - end - end - value - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/substitutions/command.rb new/lib/dotenv/substitutions/command.rb --- old/lib/dotenv/substitutions/command.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/substitutions/command.rb 1980-01-02 01:00:00.000000000 +0100 @@ -20,7 +20,7 @@ ) /x - def call(value, _env, overwrite: false) + def call(value, env) # Process interpolated shell commands value.gsub(INTERPOLATED_SHELL_COMMAND) do |*| # Eliminate opening and closing parentheses @@ -31,7 +31,7 @@ $LAST_MATCH_INFO[0][1..] else # Execute the command and return the value - `#{command}`.chomp + `#{Variable.call(command, env)}`.chomp end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/substitutions/variable.rb new/lib/dotenv/substitutions/variable.rb --- old/lib/dotenv/substitutions/variable.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/substitutions/variable.rb 1980-01-02 01:00:00.000000000 +0100 @@ -12,29 +12,23 @@ VARIABLE = / (\\)? # is it escaped with a backslash? (\$) # literal $ - (?!\() # shouldnt be followed by paranthesis + (?!\() # shouldn't be followed by parenthesis \{? # allow brace wrapping ([A-Z0-9_]+)? # optional alpha nums \}? # closing brace /xi - def call(value, env, overwrite: false) - combined_env = overwrite ? ENV.to_h.merge(env) : env.merge(ENV) + def call(value, env) value.gsub(VARIABLE) do |variable| match = $LAST_MATCH_INFO - substitute(match, variable, combined_env) - end - end - - private - def substitute(match, variable, env) - if match[1] == "\\" - variable[1..] - elsif match[3] - env.fetch(match[3], "") - else - variable + if match[1] == "\\" + variable[1..] + elsif match[3] + env[match[3]] || ENV[match[3]] || "" + else + variable + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/template.rb new/lib/dotenv/template.rb --- old/lib/dotenv/template.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/template.rb 1980-01-02 01:00:00.000000000 +0100 @@ -34,7 +34,7 @@ def var_defined?(line) match = Dotenv::Parser::LINE.match(line) - match && match[1] + match && match[:key] end def line_blank?(line) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv/version.rb new/lib/dotenv/version.rb --- old/lib/dotenv/version.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv/version.rb 1980-01-02 01:00:00.000000000 +0100 @@ -1,3 +1,3 @@ module Dotenv - VERSION = "3.1.4".freeze + VERSION = "3.2.0".freeze end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/dotenv.rb new/lib/dotenv.rb --- old/lib/dotenv.rb 2024-09-18 05:54:04.000000000 +0200 +++ new/lib/dotenv.rb 1980-01-02 01:00:00.000000000 +0100 @@ -55,7 +55,7 @@ begin env = Environment.new(File.expand_path(filename), overwrite: overwrite) env = block.call(env) if block - rescue Errno::ENOENT + rescue Errno::ENOENT, Errno::EISDIR raise unless ignore end @@ -94,13 +94,21 @@ # Update `ENV` with the given hash of keys and values # # @param env [Hash] Hash of keys and values to set in `ENV` - # @param overwrite [Boolean] Overwrite existing `ENV` values + # @param overwrite [Boolean|:warn] Overwrite existing `ENV` values def update(env = {}, overwrite: false) instrument(:update) do |payload| diff = payload[:diff] = Dotenv::Diff.new do ENV.update(env.transform_keys(&:to_s)) do |key, old_value, new_value| # This block is called when a key exists. Return the new value if overwrite is true. - overwrite ? new_value : old_value + case overwrite + when :warn + # not printing the value since that could be a secret + warn "Warning: dotenv not overwriting ENV[#{key.inspect}]" + old_value + when true then new_value + when false then old_value + else raise ArgumentError, "Invalid value for overwrite: #{overwrite.inspect}" + end end end diff.env diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2024-09-18 05:54:04.000000000 +0200 +++ new/metadata 1980-01-02 01:00:00.000000000 +0100 @@ -1,14 +1,13 @@ --- !ruby/object:Gem::Specification name: dotenv version: !ruby/object:Gem::Version - version: 3.1.4 + version: 3.2.0 platform: ruby authors: - Brandon Keepers -autorequire: bindir: bin cert_chain: [] -date: 2024-09-18 00:00:00.000000000 Z +date: 1980-01-02 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rake @@ -85,7 +84,7 @@ - MIT metadata: changelog_uri: https://github.com/bkeepers/dotenv/releases -post_install_message: + funding_uri: https://github.com/sponsors/bkeepers rdoc_options: [] require_paths: - lib @@ -100,8 +99,7 @@ - !ruby/object:Gem::Version version: '0' requirements: [] -rubygems_version: 3.5.16 -signing_key: +rubygems_version: 3.6.9 specification_version: 4 summary: Loads environment variables from `.env`. test_files: []
