Last active
March 15, 2022 07:50
-
-
Save phw/8b2b34e8b0c848ca4d8946cbaf9da775 to your computer and use it in GitHub Desktop.
Picard pre-commit hook using PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
exec pwsh.exe -NoProfile -ExecutionPolicy Bypass -File ./.git/hooks/pre-commit.ps1 | |
exit $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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