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

Add a option to skip the command if the file list is empty #446

Closed
robsonpeixoto opened this issue Mar 15, 2023 · 4 comments · Fixed by #448
Closed

Add a option to skip the command if the file list is empty #446

robsonpeixoto opened this issue Mar 15, 2023 · 4 comments · Fixed by #448
Labels
feature request A new lefthook feature description

Comments

@robsonpeixoto
Copy link

⚡ Summary

Sometimes is very annoying compile the project just because you change the Dockerfile or a README.
Now the Command is only skipped if the {files} template is used, but sometimes is not possible to use it on the run configurations.

Behavior and configuration changes

Add a configuration to skip the command if the list of files is empty. Example:

pre-commit:
  parallel: true
  commands:
    compile_1st_suggestion:
      glob: "*.{ex,exs}"
      run: mix compile
      skip_empty: {staged_files}
      env:
        MIX_ENV: prod
    compile_2nd_suggestion:
      glob: "*.{ex,exs}"
      run: mix compile
      skip:
        - is_empty: {staged_files}
      env:
        MIX_ENV: prod
@robsonpeixoto robsonpeixoto added the feature request A new lefthook feature description label Mar 15, 2023
@mrexox
Copy link
Member

mrexox commented Mar 15, 2023

Hey @robsonpeixoto , I'm thinking of this for quite a long time. It feels like if you've specified the glob or exclude you definitely want to skip command if files are missing. For pre-commit hook it is {staged_files}, for pre-push it is {push_files}. What do you think if this happens implicitly? I think that's what many people expect as a default behavior without explicit skip option. 🤔

@robsonpeixoto
Copy link
Author

What do you think if this happens implicitly?

I'll love, @mrexox <3

@mrexox
Copy link
Member

mrexox commented Mar 16, 2023

Please, check it in a new release v1.3.6

@robsonpeixoto
Copy link
Author

Thanks @mrexox <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants