lefthook: Don't run tool if no file to work on

Hello,

Possible bug I saw during test lefthook.

Actual behavior

When no {staged_files} is empty (SKIP. NO FILES FOR INSPECTING) is output but the command is called.

Waited behavior

The command is not called

Herve-M

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15

Most upvoted comments

Tested locally 0.6.5, problem seem to be solved 😃

Thanks @Arkweid!

It would be great if someone take care of this. The problem should be easy to fix. Here is the filter functions: https://github.com/Arkweid/lefthook/blob/master/cmd/run_windows.go#L188-L190

files = FilterGlob(files, getCommandGlobRegexp(hooksGroup, commandName))
files = FilterInclude(files, getCommandIncludeRegexp(hooksGroup, commandName))
files = FilterExclude(files, getCommandExcludeRegexp(hooksGroup, commandName))

Need to add another one, like filterEmpty and just cut all empty "" names from files array.