Skip to content

Instantly share code, notes, and snippets.

@KScaesar
Created July 3, 2024 15:28
Show Gist options
  • Select an option

  • Save KScaesar/aa03d78cee693fbd55258f32f9c033b9 to your computer and use it in GitHub Desktop.

Select an option

Save KScaesar/aa03d78cee693fbd55258f32f9c033b9 to your computer and use it in GitHub Desktop.
check git commit-msg
#!/bin/sh
commit_msg_file=$1
commit_msg=$(cat "$commit_msg_file")
date_regex="^[0-9]{4}-[0-9]{2}-[0-9]{2}"
if ! echo "$commit_msg" | grep -qE "$date_regex"; then
echo "Error: commit message must start with a date in YYYY-MM-DD format."
exit 1
fi
exit 0
@KScaesar
Copy link
Author

KScaesar commented Jul 3, 2024

chmod +x .git/hooks/commit-msg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment