fixes
This commit is contained in:
parent
200495442f
commit
17336c0470
|
@ -31,7 +31,7 @@ class InstallCommand extends Command
|
|||
$git_directory = base_path('.git');
|
||||
$git_hooks_directory = "{$git_directory}/hooks";
|
||||
|
||||
$this->line("Checking Git hooks directory...");
|
||||
$this->line("Updating Git hooks...");
|
||||
|
||||
if (! is_dir($git_directory)) {
|
||||
$this->error("Could not install hooks: $git_directory is not a Git repository");
|
||||
|
@ -61,6 +61,10 @@ class InstallCommand extends Command
|
|||
$this->error("Could not install hooks: could not create Git hook file $git_hook_file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
passthru("chmod +x $git_hook_file");
|
||||
|
||||
$this->line("Installed Git hook file: $git_hook_file");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,31 +1,34 @@
|
|||
#!/bin/bash
|
||||
|
||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$")
|
||||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')
|
||||
|
||||
# Disable if it's a merge
|
||||
git merge HEAD &> /dev/null
|
||||
IS_MERGE_PROCESS=$?
|
||||
if [ $IS_MERGE_PROCESS -ne 0 ]
|
||||
then
|
||||
echo -e "\e[92m Skipping pre-commit hook. \e[0m"
|
||||
echo -e "Skipping pre-commit hook."
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Skip if no staged files
|
||||
if [[ "$STAGED_FILES" = "" ]]; then
|
||||
echo -e "\e[92m No staged files. Skipping pre-commit hook. \e[0m"
|
||||
echo -e "No staged files. Skipping pre-commit hook."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\e[92m Running pre-commit hooks... \e[0m"
|
||||
echo -e "Running pre-commit hooks..."
|
||||
|
||||
./artisan hooks:pre-commit
|
||||
|
||||
if [[ "$?" == 0 ]]; then
|
||||
echo -e "\e[102m Pre-commit hooks passed \e[0m"
|
||||
echo -e "Pre-commit hooks passed!"
|
||||
else
|
||||
echo -e "\e[102m Pre-commit hooks failed \e[0m"
|
||||
echo -e "Pre-commit hooks failed!"
|
||||
echo -e "If you want to skip pre-commit hooks, use --no-verify option."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git add STAGED_FILES
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue