Skip to content

Instantly share code, notes, and snippets.

Created August 27, 2022 10:59
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Pre-commit Git hook that validates Sitecore serialization
# Pre-commit Git hook
# It runs Sitecore CLI Serialization check
# And doesn't allow to perform commit if serialization is broken
validate=$(dotnet sitecore ser validate)
regex_errors="Errors were detected"
count=$(echo "${validate}" | grep -c "${regex_errors}")
if test $count -gt 0
echo "Sitecore serialization errors were detected"
echo "Please run 'dotnet sitecore ser validate'"
echo "And fix all errors before commit"
exit 1
exit 0
Copy link

How to use:

  1. Download this file
  2. Put it under \.git\hooks in your repository
  3. Remove .sh extension (it needs in GitHub Gist for syntax highlighting)
  4. Enjoy pushing Sitecore serialization without mistakes 👍

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