Skip to content

Instantly share code, notes, and snippets.

@phw
Last active March 15, 2022 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phw/8b2b34e8b0c848ca4d8946cbaf9da775 to your computer and use it in GitHub Desktop.
Save phw/8b2b34e8b0c848ca4d8946cbaf9da775 to your computer and use it in GitHub Desktop.
Picard pre-commit hook using PowerShell
#!/bin/sh
exec pwsh.exe -NoProfile -ExecutionPolicy Bypass -File ./.git/hooks/pre-commit.ps1
exit $?
#!/usr/bin/env pwsh
$ErrorActionPreference = "Stop"
$PyFiles = git diff --cached --name-only `
| Select-String -Pattern ".*\.py$" `
| Select-String -NotMatch -Pattern "^picard/ui/ui_.*\.py$", "^picard/resources\.py$", "^picard/const/__init__\.py$"
If ($PyFiles) {
isort --check-only --diff --quiet $PYFILES
If ($LastExitCode -ne 0) {
exit $LastExitCode
}
flake8 $PYFILES
exit $LastExitCode
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment