Put the pre-commit file under .git/hooks/ of your Dart and/or Flutter project, and make sure it is well-formatted (LF) and it has the correct permissions.
The following steps will get you the pre-commit hook in your project:
cd path/to/your/projectcurl -fsSL "https://gist.githubusercontent.com/Cynnexis/16b64199d9a94684a638f08b3fc893d3/raw/pre-commit" -o .git/hooks/pre-commitchmod 776 .git/hooks/pre-commit- If you use Windows:
dos2unix .git/hooks/pre-commit
If you want to automate its creation from a Makefile, use the following rule:
.PHONY: help configure-git configure
# [...]
help:
# [...]
@echo " configure - Configure the project folder."
@echo " configure-git - Configure the project folder for git usage. Use 'configure' for global configuration of the project."
# [...]
.git/hooks/pre-commit:
curl -fsSL "https://gist.githubusercontent.com/Cynnexis/16b64199d9a94684a638f08b3fc893d3/raw/pre-commit" -o ".git/hooks/pre-commit"
@if command -v "dos2unix" > /dev/null 2>&1; then \
dos2unix ".git/hooks/pre-commit"; \
else \
echo "dos2unix not found. If you are on Windows, you may consider installing it."; \
fi
configure-git: .git/hooks/pre-commit
configure: configure-git
# [...]