承接 sonrac/git-php-hook-runner 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sonrac/git-php-hook-runner

Composer 安装命令:

composer require sonrac/git-php-hook-runner

包简介

Pre commit hook for php projects

README 文档

README

The package is a utility for git hooks configuration to speed up the work of git hooks.

Hook commands are launched in parallel and due to parallelization the hook works faster.

Installation

composer require sonrac/git-php-hook-runner

Usages

  • Copy config
cp vendor/sonrac/git-hook-runner/config/hook.yaml /<path-to-source-root>/<path-to-new-location-config>
  • Edit hook configuration. Full options list see here
  • Create hook in .git/hooks directory with next content
#!/bin/sh

set -e

XDEBUG_MODE=off
set -e

XDEBUG_MODE=off

PROJECT_DIR="$(dirname ${0})/../../"

__docker_cmd_runner() {
  docker-compose exec -T -e XDEBUG_MODE=off php "$@"
}

CHANGED_FILES=$(git -C "$PROJECT_DIR" diff --staged --relative --name-only --diff-filter=ACMR)

if [ -z "$CHANGED_FILES" ]; then
  echo "Empty changed files list"
  exit 0;
fi

echo '\nRun PHPCS Beautifier:\n'

__docker_cmd_runner which ./vendor/bin/phpcbf
if [ $? -eq 1 ]; then
  echo "\033[41mPlease install PHPCS\033[0m"
  exit 1
fi

PHPCBF_OUTPUT=$(__docker_cmd_runner ./vendor/bin/phpcbf $CHANGED_FILES)

case $? in
  0)
    echo "\033[32mNothing found that could be fixed \033[0m"
    ;;
  1)
    echo "\033[32mPHPCBF fixed all fixable errors \033[0m"
    ;;
  2)
    echo "\033[43mSomething failed to fix. Please change your files \033[0m"
    exit 1
    ;;
esac

BEAUTIFIED_FILES=$(echo "$PHPCBF_OUTPUT" | grep 'src\|tests\|app' |  awk -v pr_dir="$PROJECT_DIR" '{print pr_dir$1}' | tr -s '\r\n' ' ');

if [ ! -z "$BEAUTIFIED_FILES" ]; then
  git add $BEAUTIFIED_FILES
fi

php ../../vendor/bin/hook hook -p  <path-to-source-root> -c <path-to-new-location-config> $CHANGED_FILES
  • Save hook file content
  • Git execute rights for git hook
chmod +x .git/hook/<git-hook-file-name>

Disable hook for commit

Uncheck checkbox in commit modal dialogue if you need commit without hook runner checks

img.png

Useful Links

sonrac/git-php-hook-runner 适用场景与选型建议

sonrac/git-php-hook-runner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sonrac/git-php-hook-runner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sonrac/git-php-hook-runner 我们能提供哪些服务?
定制开发 / 二次开发

基于 sonrac/git-php-hook-runner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-21