Skip to content

gemfile:false option no longer behaves as expected in YAML config #862

@arthurthefourth

Description

@arthurthefourth

As of 0.65, when I run overcommit with gemfile: false in the config, I get the following error:

Problem loading 'false': my-code-directory/false not found

It seems like when #859 started using regex to parse the gemfile config instead of YAML, we ended up losing some nice YAML.parse functionality?

# .overcommit.yml
gemfile: false

# hook code
config = File.read('.overcommit.yml') =~ /gemfile: ['"]?(.*)['"]?/
gemfile = Regexp.last_match(1) # gemfile is now set to the (truthy) string "false"

if gemfile # this is triggered with gemfile = 'false'
  ENV['BUNDLE_GEMFILE'] = gemfile

  begin
    Bundler.setup
  rescue Bundler::BundlerError => e
    puts "Problem loading '#{gemfile}': #{e.message}" # Problem loading 'false'
    puts "Try running:\nbundle install --gemfile=#{gemfile}" if e.is_a?(Bundler::GemNotFound)
    exit 78 # EX_CONFIG
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions