evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.66k stars 211 forks source link

`exclude` configuration as array #717

Closed dalisoft closed 1 month ago

dalisoft commented 3 months ago

:zap: Summary

I would like to see exclude array support

Value

exclude:
  - bun.lockb
  - package-lock.json
  - yarn.lock
  - pnpm-lock.yaml

Behavior and configuration changes

Currently configuration is like this:

prepare-commit-msg:
  commands:
    commitlint:
      env:
        PATH: $PATH:./node_modules/.bin
      run: commitlint --edit

pre-commit:
  parallel: true
  commands:
    biome:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.{js,ts,jsx,tsx,json,jsonc}"
      run: biome check {staged_files} --apply
    markdown:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.md"
      run: dprint fmt {staged_files}
    docker:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "Dockerfile"
      run: dprint fmt {staged_files}
    typos:
      env:
        PATH: $PATH:./node_modules/.bin
      exclude: "bun.lockb|package-lock.json|yarn.lock|pnpm-lock.yaml"
      run: typos {staged_files}

pre-push:
  parallel: true
  commands:
    biome:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.{js,ts,jsx,tsx,json,jsonc}"
      run: biome check {all_files}
    markdown:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.md"
      run: dprint check {all_files}
    docker:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "Dockerfile"
      run: dprint check {all_files}
    typos:
      env:
        PATH: $PATH:./node_modules/.bin
      exclude: "bun.lockb|package-lock.json|yarn.lock|pnpm-lock.yaml"
      run: typos {all_files}

And i would like to see like this

prepare-commit-msg:
  commands:
    commitlint:
      env:
        PATH: $PATH:./node_modules/.bin
      run: commitlint --edit

pre-commit:
  parallel: true
  commands:
    biome:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.{js,ts,jsx,tsx,json,jsonc}"
      run: biome check {staged_files} --apply
    markdown:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.md"
      run: dprint fmt {staged_files}
    docker:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "Dockerfile"
      run: dprint fmt {staged_files}
    typos:
      env:
        PATH: $PATH:./node_modules/.bin
-    exclude: "bun.lockb|package-lock.json|yarn.lock|pnpm-lock.yaml"
+    exclude:
        - bun.lockb
        - package-lock.json
        - yarn.lock
        - pnpm-lock.yaml
      run: typos {staged_files}

pre-push:
  parallel: true
  commands:
    biome:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.{js,ts,jsx,tsx,json,jsonc}"
      run: biome check {all_files}
    markdown:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "*.md"
      run: dprint check {all_files}
    docker:
      env:
        PATH: $PATH:./node_modules/.bin
      glob: "Dockerfile"
      run: dprint check {all_files}
    typos:
      env:
        PATH: $PATH:./node_modules/.bin
-     exclude: "bun.lockb|package-lock.json|yarn.lock|pnpm-lock.yaml"
+     exclude:
        - bun.lockb
        - package-lock.json
        - yarn.lock
        - pnpm-lock.yaml
      run: typos {all_files}
pvcresin commented 1 month ago

I too would like this feature. It's hard with regular expressions when I want to set up multiple files in different directory hierarchies.