Comparing 44510:master...sds:main · 44510/overcommit

Commits on Jun 24, 2024

  1. Configuration menu

    Browse the repository at this point in the history

Commits on Jul 22, 2024

  1. Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Aug 11, 2024

  1. Fix spec compatibility with recent git versions (sds#854)

    The original array was defining the shellwords like this:
    `["git", "commit", "-m", "\"Resolve", "conflicts\"", "-i", "some-file"]`
    
    This combined with the most recent git version failed with:
    ```
    error: pathspec 'conflicts"' did not match any file(s) known to git
    ```
    
    This PR just simplifies the commit message to work with the %w array
    literal.
    Configuration menu

    Browse the repository at this point in the history

  2. Expand tildes(~) for hooksPath (sds#853)

    While installing overcommit git hooks i noticed that tildes are not
    expanded to home folders for the `hooksPath` config, the result was a
    tilde folder in the current directory.
    
    This PR addresses that by switching `File.absolute_path` to
    `File.expand_path`. The [underlaying
    implementation](https://github.com/ruby/ruby/blob/v3_3_4/file.c#L3753)
    in Ruby is exactly the same just with this difference in how `~` is
    handled.
    
    ---------
    
    Co-authored-by: Shane da Silva <shane@dasilva.io>
    Configuration menu

    Browse the repository at this point in the history

Commits on Oct 31, 2024

  1. Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Jan 27, 2025

  1. Load bundled gems on expected version (sds#859)

    Fixes sds#789
    
    `psych` is no longer a default gem, but current and old ruby still ships
    with it. When we `require 'yaml'`, we activate that gem in whatever
    version that is bundled with ruby. Later on, we load bundler, and we
    `Bundler.setup`, which will then activate whatever version specified in
    the lock file. More often than not, they might not match.
    
    The approach in this PR is to strip the `yaml` dependency completely
    from the hook scripts, while retaining the ability to configure the
    Gemfile using it.
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Jan 30, 2025

  1. Add -diff cli option for running precommit hooks against diffs (sds…

    …#860)
    
    For example, running `overcommit --diff main` from a feature branch will
    run pre-commit hooks against the diff between the two branches.
    
    I was able to very easily leverage existing code for the bulk of the
    feature - this is mainly just adding the cli option, a hook context to
    do the execution and some tests based on the existing `--run-all` test.
    
    ---
    
    For background, my team is responsible for a couple of really old,
    really large rails apps. Getting them completely in compliance with our
    various linters is a huge task that isn't getting done anytime soon
    (things are funky to the point that we've even observed breakages with
    "safe" auto-correct functions).
    
    I introduced/started heavily encouraging overcommit so that we at least
    don't add _new_ linting offenses and things will naturally improve over
    time. It's been great, but offenses still slip through though here and
    there, especially with juniors who might be getting away with not having
    a local install (and/or abusing `OVERCOMMIT_DISABLE=1`).
    
    An option like this would allow me to leverage the very useful "only
    apply to changed lines" logic within a ci environment and help enforce
    my desired "no new linting offenses" policy.
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Feb 16, 2025

  1. Restore ability to specify "gemfile: false" in config (sds#863)

    Setting `gemfile: false` in `.overcommit.yml` is supposed to disable
    Bundler. However, a recently-introduced bug causes `false` to be
    interpreted as the name of the gemfile. Bundler looks for a gemfile
    named "false", which fails, leading overcommit's hooks to crash.
    
    This PR fixes the bug by adjusting the regex used to parse the
    `gemfile:` line in the config. Now, `false` is no longer interpreted as
    a gemfile name.
    
    I added an integration test to verify the fix.
    
    Fixes sds#862
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Feb 19, 2025

  1. Add note about unsupported YAML features in gemfile: line in defaul…

    …t.yml (sds#865)
    
    Related to sds#863 and [this
    comment](sds#862 (comment)):
    
    > Having a similar problem since we had this line in our
    `.overcommit.yml`:
    > 
    > ```yaml
    > 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
    > ```
    
    I think adding support for comments in the `gemfile:` regexp is likely
    overkill and may still not be enough when the next person tries to use
    yet another YAML feature in that line, but perhaps this little warning
    would help someone else avoid tripping.

    pilaf authored

    Feb 19, 2025
    Configuration menu

    Browse the repository at this point in the history

Commits on Mar 3, 2025

  1. adds 'set' requirements to diff hook context. (sds#866)

    Running `overcommit` with the `--diff` flag results in errors for
    version `0.67.0`.
    
    ```sh
    bundle exec overcommit --diff HEAD
    ```
    
    It results on the following:
    
    ```ruby
    Running pre-commit hooks
    Check for case-insensitivity conflicts................[CaseConflicts] FAILED
    Hook raised unexpected error
    uninitialized constant Overcommit::Hook::PreCommit::CaseConflicts::Set
    
          repo_files = Set.new(applicable_files)
                       ^^^
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook/pre_commit/case_conflicts.rb:8:in `run'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook/base.rb:47:in `block in run_and_transform'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/utils.rb:260:in `with_environment'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook/base.rb:47:in `run_and_transform'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:162:in `run_hook'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:98:in `block in consume'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:94:in `loop'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:94:in `consume'
    Analyze with RuboCop........................................[RuboCop] FAILED
    Hook raised unexpected error
    uninitialized constant Overcommit::GitRepo::Set
    
          lines = Set.new
                  ^^^
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/git_repo.rb:69:in `extract_modified_lines'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_context/diff.rb:17:in `modified_lines_in_file'
    /nix/store/0sj7d3r1kf95f27028j93j0sx3v6p1kw-ruby-3.1.6/lib/ruby/3.1.0/forwardable.rb:238:in `modified_lines_in_file'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:145:in `message_on_modified_line?'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:138:in `block in remove_ignored_messages'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:138:in `select'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:138:in `remove_ignored_messages'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:45:in `handle_modified_lines'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/message_processor.rb:39:in `hook_result'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook/base.rb:263:in `process_hook_return_value'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook/base.rb:48:in `run_and_transform'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:162:in `run_hook'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:98:in `block in consume'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:94:in `loop'
    .bundle/ruby/3.1.0/gems/overcommit-0.67.0/lib/overcommit/hook_runner.rb:94:in `consume'
    
    ✗ One or more pre-commit hooks failed
    ```
    
    The problems are fixed once `set` is required in the context that the
    sub command is run.
    
    `run_all.rb` also requires `set` where the module is
    [defined](https://github.com/sds/overcommit/blob/main/lib/overcommit/hook_context/run_all.rb#L3).

    rscnt authored

    Mar 3, 2025
    Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history

Commits on Jun 29, 2025

  1. Update RuboCop in Gemfile to silence a deprecation warning in build (s…

    …ds#870)
    
    The existing version of RuboCop no longer works against other libraries
    without deprecation warnings; rather than lock more dependencies,
    upgrade RuboCop used in project.
    
    ```sh
    Running pre-commit hooks
    Check YAML syntax........................................[YamlSyntax] OK
    Check Gemfile dependencies..............................[BundleCheck] OK
    Check for trailing whitespace....................[TrailingWhitespace] OK
    Analyze with RuboCop........................................[RuboCop] FAILED
    Unexpected output: unable to determine line number or type of error/warning for output:
    `EnsureNode#body` is deprecated and will be changed in the next major version of rubocop-ast. Use `EnsureNode#branch` instead to get the body of the `ensure` branch.
    Called from:
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/layout/indentation_width.rb:67:in `on_ensure'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:105:in `each'
    /Users/broz/.rbenv/versions/3.1.6/lib/ruby/gems/3.1.0/gems/rubocop-1.63.0/lib/rubocop/cop/commissioner.rb:105:in
    `trigger_responding_cops'
    [...]
    ```
    Configuration menu

    Browse the repository at this point in the history

Commits on Jun 30, 2025

  1. Configuration menu

    Browse the repository at this point in the history

  2. Configuration menu

    Browse the repository at this point in the history