Created
August 27, 2022 10:59
-
-
Save Antonytm/1c1efdd3fb61cc31f97a3f0dac686389 to your computer and use it in GitHub Desktop.
Pre-commit Git hook that validates Sitecore serialization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 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 | |
then | |
echo "Sitecore serialization errors were detected" | |
echo "Please run 'dotnet sitecore ser validate'" | |
echo "And fix all errors before commit" | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
\.git\hooks
in your repository.sh
extension (it needs in GitHub Gist for syntax highlighting)