diff --git a/.github/workflows/dotnet-core.yaml b/.github/workflows/dotnet-core.yaml index 5a65c87..c7159d8 100644 --- a/.github/workflows/dotnet-core.yaml +++ b/.github/workflows/dotnet-core.yaml @@ -26,4 +26,4 @@ jobs: - name: Install Fantomas run: dotnet tool restore - name: Run Fantomas - run: dotnet tool run fantomas --check -r . + run: ./hooks/pre-push diff --git a/hooks/pre-push b/hooks/pre-push new file mode 100755 index 0000000..ab3341d --- /dev/null +++ b/hooks/pre-push @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import subprocess + +def check_fantomas(): + result = subprocess.run(["dotnet", "tool", "run", "fantomas", "--check", "-r", "."]) + if result.returncode != 0: + print(result.stdout) + raise Exception(f"Formatting incomplete (return code: {result.returncode}). Consider running `dotnet tool run fantomas -r .`") + + +def main(): + check_fantomas() + + +if __name__ == "__main__": + main()