Add pre-push hook

This commit is contained in:
Smaug123
2022-10-24 13:01:38 +01:00
parent d919dddb4e
commit 0acf5f7d4c
2 changed files with 18 additions and 1 deletions

View File

@@ -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

17
hooks/pre-push Executable file
View File

@@ -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()