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

pre-commit flag --files is not respected #562

Open
piankris opened this issue Apr 11, 2023 · 1 comment
Open

pre-commit flag --files is not respected #562

piankris opened this issue Apr 11, 2023 · 1 comment

Comments

@piankris
Copy link

piankris commented Apr 11, 2023

I have a yamllint config file and I use it together in the pre-commit hook. What I'm trying to achieve is to run the hook only on specified files (in my case, files changed in a pull request) but the hook ignores the --files flag and instead runs on all yaml files.

My yamllint config:

---
yaml-files:
    - '*.yaml'
    - '*.yml'
    - .yamllint

ignore: |
    d2b_dbt/
    .venv/

rules:
    braces:
        level: warning
        min-spaces-inside: 0
        max-spaces-inside: 0
        min-spaces-inside-empty: 1
        max-spaces-inside-empty: 5
    brackets:
        level: warning
        min-spaces-inside: 0
        max-spaces-inside: 0
        min-spaces-inside-empty: 1
        max-spaces-inside-empty: 5
    colons:
        level: warning
        max-spaces-before: 0
        max-spaces-after: 1
    commas:
        level: warning
        max-spaces-before: 0
        min-spaces-after: 1
        max-spaces-after: 1
    comments: disable
    comments-indentation: disable
    document-end: disable
    document-start: disable
    empty-lines:
        level: warning
        max: 2
        max-start: 0
        max-end: 0
    hyphens:
        level: warning
        max-spaces-after: 1
    indentation:
        level: warning
        spaces: consistent
        indent-sequences: true
        check-multi-line-strings: false
    key-duplicates: enable
    line-length:
        ignore: |
            .github/workflows/main.yml
            .github/workflows/redshift-dbt-ci.yml
        level: warning
        max: 140
        allow-non-breakable-words: true
        allow-non-breakable-inline-mappings: true
    new-line-at-end-of-file: disable
    new-lines:
        type: unix
    trailing-spaces: disable

The command I run:

 pre-commit run yamllint --files .github/linters/.yaml-lint.yml .github/workflows/main.yml .pre-commit-config.yaml d2b_dbt/.sqlfluff

The output:

Check yaml files with yamllint...........................................Failed
- hook id: yamllint
- exit code: 2

./.github/workflows/redshift-dbt-ci.yml
  10:3      warning  wrong indentation: expected 4 but found 2  (indentation)
  11:5      warning  wrong indentation: expected 6 but found 4  (indentation)
  14:7      warning  wrong indentation: expected 8 but found 6  (indentation)
  17:11     warning  wrong indentation: expected 12 but found 10  (indentation)
  25:11     warning  wrong indentation: expected 12 but found 10  (indentation)
@adrienverge
Copy link
Owner

Hello,

I'm not sure I fully understand your problem, but your question seems related to pre-commit and it --files option. I suggest using a community-powered Q&A service, like Stack Overflow for topics like this. This issue tracker is only meant for bugs regarding yamllint.

Thank you!

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

No branches or pull requests

2 participants