Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arthurthefourth opened this issue Jan 30, 2025 · 2 comments
Open
Labels

Comments

@arthurthefourth
Copy link

arthurthefourth commented Jan 30, 2025

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
@sds
Copy link
Owner

sds commented Feb 3, 2025

Heads up @xjunior: looks like this was introduced by #859.

@sds sds added the bug label Feb 3, 2025
@pilaf
Copy link

pilaf commented Feb 7, 2025

Having a similar problem since we had this line in our .overcommit.yml:

gemfile: Gemfile # enforce bundled version of overcommit

And now overcommit doesn't strip out the inline comment, resulting in this weird looking error message:

Problem loading 'Gemfile # enforce bundled version of overcommit': /path/to/project/Gemfile # enforce bundled version of overcommit not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants