.git/hooks/precommit
write a bash script, will be executed after git commit
Create a file named pre-commit
(without any extension) in your .git/hooks/
directory within your Git repository. Ensure this file is executable (chmod +x .git/hooks/pre-commit
).
precommit need to check pwd see where root folder is
code check bin using go
https://github.com/Done-0/fuck-u-code
GIT does not upload this to remote, so it must be local
#!/bin/bash
pwd
# Define the path to your Go executable
GO_EXECUTABLE=".git/hooks/fuck-u-code"
# Check if the Go executable exists
if [ ! -f "$GO_EXECUTABLE" ]; then
echo "Error: Executable '$GO_EXECUTABLE' not found in the same directory as the hook."
exit 1
fi
# Run the Go executable
"$GO_EXECUTABLE" analyze rootsubfod1/cli
# Check the exit status of the Go executable
if [ $? -ne 0 ]; then
echo "Check code failed. Aborting commit."
exit 1
fi
echo "Check code finished successfully. Please record the analysis, proceeding with commit."
exit 0
No comments:
Post a Comment