Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pre-commit as a dependency #1494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml

This file was deleted.

31 changes: 31 additions & 0 deletions Scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi

#Run dotnet-format on the changed dafny sources
dotnet_format=$(git diff --cached --name-only --diff-filter=ACMR -z $against | grep -a '^Source.*.cs$' | xargs -0 dotnet tool run dotnet-format --folder -w --include)

#Abort on fail (likely no dotnet-format)
if (( $? > 0 ));
then
exit 1
fi

#Eval dotnet-format output
if (( $(echo "$dotnet_format" | wc -l) > 2));
then
cat <<\EOF
Error: Staged file(s) violate the formatting rules.

Fortunately, we took the liberty to fix that.

All that is left to do, is to *add the changes* and recommit.
EOF
exit 1
fi