Skip to content

Commit

Permalink
Revert 541ae16
Browse files Browse the repository at this point in the history
  • Loading branch information
kayw-geek committed May 24, 2024
1 parent 541ae16 commit bd92a4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quality Hook Installer

Install an execute script of specify quality tools to your git pre-add hook, and it executes only for changed files
Install an execute script of specify quality tools to your git pre-commit hook, and it executes only for changed files
## Install

```BASH
Expand All @@ -12,18 +12,18 @@ composer global require kayw/quality-hook-installer
1. `quality run install --phpstan --php-cs-fixer`
2. Execute `git add .` in your project.
3. `git commit -m 'xxx'`
4. The pre-add hook will be triggered and the PHPStan and PHPCsFixer will execute only for changed files.
4. The pre-commit hook will be triggered and the PHPStan and PHPCsFixer will execute only for changed files.

## Commands

The following command will execute quality inspection only for changed files

`quality run --phpstan --php-cs-fixer`

The following command will write in your pre-add of git hook
The following command will write in your pre-commit of git hook

`quality run install --phpstan --php-cs-fixer`

The following command will remove your pre-add of git hook
The following command will remove your pre-commit of git hook

`quality run uninstall`
10 changes: 5 additions & 5 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class RunCommand extends Command
protected function configure(): void
{
$this->setDescription('Put code quality inspection to git hook');
$this->setHelp('Install an execute script of specify quality tools to your git pre-add hook, and it executes only for changed files');
$this->addArgument(self::ARGUMENT_INSTALL, InputArgument::OPTIONAL, 'Install a execute script of specify quality tools to your git per-add hook');
$this->addArgument(self::ARGUMENT_UNINSTALL, InputArgument::OPTIONAL, 'Uninstall a execute script of specify quality tools to your git per-add hook');
$this->setHelp('Install an execute script of specify quality tools to your git pre-commit hook, and it executes only for changed files');
$this->addArgument(self::ARGUMENT_INSTALL, InputArgument::OPTIONAL, 'Install a execute script of specify quality tools to your git per-commit hook');
$this->addArgument(self::ARGUMENT_UNINSTALL, InputArgument::OPTIONAL, 'Uninstall a execute script of specify quality tools to your git per-commit hook');
$this->addOption(self::OPTION_PHPSTAN, '', InputOption::VALUE_NONE);
$this->addOption(self::OPTION_PHP_FIXER, '', InputOption::VALUE_NONE);
}
Expand Down Expand Up @@ -69,7 +69,7 @@ private function checkPhpCsFixerConfigFileExist(): bool

private static function getChangedFilesString(): ?string
{
exec('git diff --name-only --diff-filter=M', $exec_output);
exec('git diff --name-only HEAD --diff-filter=M', $exec_output);

return implode(' ', $exec_output);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ private function executeInstall(array $active_options, InputInterface $input, Ou
exec </dev/tty
eval "quality run $option_text"
EOF;
file_put_contents($this->getPath() . '/.git/hooks/pre-add', $execute_command);
file_put_contents($this->getPath() . '/.git/hooks/pre-commit', $execute_command);
$output->writeln('<info> The hook install success! </info>');

return self::SUCCESS;
Expand Down

0 comments on commit bd92a4f

Please sign in to comment.