diff --git a/.make/git-hooks/README.md b/.make/git-hooks/README.md new file mode 100644 index 000000000..3e14d1ded --- /dev/null +++ b/.make/git-hooks/README.md @@ -0,0 +1,13 @@ +# Git hooks for iTop + +## ❓ Goal + +Those [git hooks](https://git-scm.com/docs/githooks) aims to ease developing on [iTop](https://github.com/Combodo/iTop). + +## ☑ Available hooks + +* pre-commit : rejects commit if you have at least one SCSS file staged, and no CSS file + +## ⚙ Install + +Just run install.php ! diff --git a/.make/git-hooks/install.php b/.make/git-hooks/install.php new file mode 100644 index 000000000..858a27827 --- /dev/null +++ b/.make/git-hooks/install.php @@ -0,0 +1,26 @@ + OK to commit !\n"; +exit(0); + + + +function GetFilesWithExtension($sExtension, $aFiles) { + return array_filter( + $aFiles, + function($item) use ($sExtension) { + return (endsWith($item, '.'.$sExtension)); + } + ); +} + +function endsWith( $haystack, $needle ) { + $length = strlen( $needle ); + if( !$length ) { + return true; + } + return substr( $haystack, -$length ) === $needle; +} + +function exitWithMessage($sMessage, $iCode) { + echo $sMessage; + exit($iCode); +} \ No newline at end of file