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: all files are passed in pre-commit.ci #239

Closed
Guts opened this issue Nov 18, 2021 · 4 comments
Closed

Pre-commit: all files are passed in pre-commit.ci #239

Guts opened this issue Nov 18, 2021 · 4 comments
Labels

Comments

@Guts
Copy link

Guts commented Nov 18, 2021

Hello,

First of all, thanks you for this CLI :).

I'm trying to use it as a pre-commit hook running on CI to autofix common errors from an heterogeneous pool of contributors to a static website. Here come:

Am I missing something in the configuration?


Secondary question

What's the difference between:

repos:
  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.29.0
    hooks:
      - id: markdownlint
        args:
          [
            "--config",
            ".markdownlint.json",
            "--ignore-path",
            ".markdownlintignore",
            "--fix"
          ]
        language: node
        # language_version: "14.17.6"
        pass_filenames: true
        types: [file, markdown, non-executable]

and, after #235, removing --fix from args :

  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: bf8b1484934b89c791b9aab83c2c6cc950546be4
    hooks:
      - id: markdownlint-fix
        args:
          [
            "--config",
            ".markdownlint.json",
            "--ignore-path",
            ".markdownlintignore"
          ]
        language: node
        # language_version: "14.17.6"
        pass_filenames: true
        types: [file, markdown, non-executable]
@DavidAnson
Copy link
Collaborator

This hook will process the files that are given to it and what you show here is passing the complete set of Markdown files every time, so that is what gets analyzed. Here is some information about limiting that to recently changed files: https://pre-commit.com/#usage-in-continuous-integration

The two approaches you show should be equivalent as you say. If you find they are not for some reason, please let us know!

FYI, you shouldn't need to pass anything other than id and args. Here is a simpler example to show what I mean: https://github.com/DavidAnson/Workflows/blob/main/.pre-commit-config.yaml

@Guts
Copy link
Author

Guts commented Nov 18, 2021

This hook will process the files that are given to it and what you show here is passing the complete set of Markdown files every time, so that is what gets analyzed. Here is some information about limiting that to recently changed files: https://pre-commit.com/#usage-in-continuous-integration

I have the impression that pre-commit.ci runs a pre-commit run --all instead of pre-commit run --from-ref origin/HEAD --to-ref HEAD and I can't find where to change/configure this behavior. If you hav any idea...

FYI, you shouldn't need to pass anything other than id and args.

I know but I want to be the more explicit I can making it easier to share the project configuration within my heterogeneous contributors pool :).

@DavidAnson: should we use the markdownlint-cli2 from now? I've just read your blog post but I would enjoy a direct confirmation, because we also promote the use of the vscode extension.

@Guts
Copy link
Author

Guts commented Nov 18, 2021

Ok, I've found a similar issue: pre-commit-ci/issues#90

So, it's not yet implemented and it's supposed to be part of the paid scope.

@DavidAnson
Copy link
Collaborator

I prefer CLI2, partly because it is more configurable and integrates more closely with the VS Code extension, but I know that it takes an approach that feels weird to some people. I try to encourage everyone to use what works best for their needs.

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

2 participants