#                                                                                #
#                          Lefthook configuration file:                          #
#   This file is used to configure Lefthook, a tool for managing Git hooks.      #
#                                                                                #
#   https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md   #

$schema: https://raw.githubusercontent.com/evilmartians/lefthook/refs/heads/master/schema.json

pre-commit:
  parallel: true
  commands:
    prepare:
      glob: "**/*"
      run: pnpm exec storm-git prepare
      stage_fixed: true
    pre-commit:
      glob: "**/*"
      run: pnpm exec storm-git pre-commit --files {staged_files}
      stage_fixed: true
    codeowners:
      glob: "**/CODEOWNERS"
      run: pnpm exec storm-lint codeowners
      stage_fixed: true
    zizmor:
      glob: .github/workflows/*.{yml,yaml}
      run: "zizmor --offline --config='./tools/config/zizmor.yml' .github/workflows/"
      stage_fixed: true

commit-msg:
  commands:
    validate:
      run: pnpm exec storm-git commitlint --message {1}

pre-push:
  parallel: true
  commands:
    build:
      glob: "**/*"
      run: pnpm build-dev
      stage_fixed: true
    pre-push:
      files: git diff --name-only HEAD @{push}
      glob: "**/*"
      run: pnpm exec storm-git pre-push --files {files}
      stage_fixed: true

post-merge:
  commands:
    validate:
      files: git diff --name-only HEAD @{push}
      glob: "**/*"
      run: pnpm exec storm-git post-merge --files {files}
      stage_fixed: true

post-commit:
  commands:
    validate:
      files: git diff --name-only HEAD @{push}
      glob: "**/*"
      run: pnpm exec storm-git post-commit --files {files}
      stage_fixed: true
