12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/usr/bin/env pwsh
- <
- .SYNOPSIS
- Runs flake8 to analyze Python source code for errors and best practices.
- $scriptDir = Split-Path $PSCommandPath -Parent
- $projectDir = (Get-Item $scriptDir).Parent
- Push-Location $projectDir
- $ExitCode = 0
- $GitDiff = git diff origin/master
- if ( $null -eq $GitDiff ) {
- flake8 .
- if ($LastExitCode -ne 0) { $ExitCode = $LastExitCode }
- }
- else {
- Write-Output $GitDiff | flake8 --diff
- if ($LastExitCode -ne 0) { $ExitCode = $LastExitCode }
-
- $GitDiffTempl = Write-Output $GitDiff | Select-String -Pattern "^diff .*/project_template/.*"
- if ( $null -ne $GitDiffTempl ) {
- flake8 testproject
- if ($LastExitCode -ne 0) { $ExitCode = $LastExitCode }
- }
- }
- if ($ExitCode -eq 0) {
- Write-Host -ForegroundColor Green "[✔] Flake8 passed with no errors"
- }
- else {
- Write-Host -ForegroundColor Red "[X] Flake8 exited with errors. Please resolve issues above."
- }
- Pop-Location
- exit $ExitCode
|