Запустить предварительную фиксацию в среде PHPStorm

289
Albert

Есть ли способ, которым я могу запустить свою ловушку перед фиксацией в среде, настроенной в PHPStorm? Я не могу установить плагины, так как это сценарий предварительной фиксации, который должен запускаться в любом клоне этого репозитория.

Моя среда настроена следующим образом в PHPStorm:

Environment Setup

И вот как выглядит мой сценарий:

cachedPhpFiles=$(git diff --cached --name-only | awk '$1 ~ /src\/application\/lib\/.+|(tests\/(unit|system)\/tests\/).+/') result=$(./vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --verbose --config=src/application/githooks/.php_cs.src.dist --dry-run --allow-risky=yes --using-cache=no $cachedPhpFiles 2> /dev/null) if [ $? -gt 1 ] then output="" for line in $result do if [[ $line == 'Checked' ]]; then break; fi  if [[ $line =~ [0-9]+\) ]]; then if [[ -n $output ]]; then echo $output fi output=$line output+=" " else output+=$line fi done errorFlag=true printf "Found code quality issues in the following files:\n" printf "$output\n\n" fi  if [ "$errorFlag" = true ]; then exit 1 else exit 0 fi 

И это мой .php_cs.src.distфайл:

$finder = PhpCsFixer\Finder::create();  return PhpCsFixer\Config::create() ->setRules([ '@PSR2' => true, 'align_multiline_comment' => true, 'array_indentation' => true, 'array_syntax' => [ 'syntax' => 'short', ], 'concat_space' => [ 'spacing' => 'one', ], 'linebreak_after_opening_tag' => true, 'method_argument_space' => [ 'ensure_fully_multiline' => true ], 'method_chaining_indentation' => true, 'multiline_comment_opening_closing' => true, 'no_blank_lines_after_class_opening' => true, 'no_blank_lines_after_phpdoc' => true, 'no_blank_lines_before_namespace' => true, 'no_empty_comment' => true, 'no_empty_phpdoc' => true, 'no_empty_statement' => true, 'no_trailing_comma_in_singleline_array' => true, 'phpdoc_add_missing_param_annotation' => true, 'phpdoc_no_empty_return' => true, 'phpdoc_order' => true, 'phpdoc_scalar' => true, 'phpdoc_single_line_var_spacing' => true, 'psr4' => true, 'trailing_comma_in_multiline_array' => true, 'whitespace_after_comma_in_array' => true, ]) ->setFinder($finder); 
0

0 ответов на вопрос

Похожие вопросы