From aaa40223ac06ea39a7a00b6d7cfc31e23cb0116a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 24 Jul 2019 09:48:04 +0200 Subject: [PATCH] Add captainhook/captainhook to dev environment --- Changelog | 2 + build/git-hooks/pre-commit | 75 +++---------- captainhook.json | 50 +++++++++ composer.json | 5 +- composer.lock | 215 ++++++++++++++++++++++++++++++++++++- 5 files changed, 282 insertions(+), 65 deletions(-) create mode 100644 captainhook.json diff --git a/Changelog b/Changelog index af17f9a3f..1a3d8abcc 100755 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2019-07-24 DariusIII + * Chg: Add captainhook/captainhook for dev work 2019-07-22 DariusIII * Chg: Update spatie/async (1.0.2 => 1.0.3) 2019-07-21 DariusIII diff --git a/build/git-hooks/pre-commit b/build/git-hooks/pre-commit index d5264ccbe..6b9a9462d 100755 --- a/build/git-hooks/pre-commit +++ b/build/git-hooks/pre-commit @@ -1,64 +1,15 @@ -#!/usr/bin/env bash -#version=10 -# -# The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". +#!/usr/bin/env php +/dev/null 2>&1 -then - AGAINST=HEAD -else - # Initial commit: diff against an empty tree object - AGAINST=4b825dc642cb6eb9a060e54bf8d69288fbee4904 -fi +if (!file_exists($autoLoader)) { + fwrite(STDERR, 'Composer autoload.php could not be found'); + exit(1); +} +require $autoLoader; +$config = realpath(__DIR__ . '/../../captainhook.json'); +$app = new CaptainHook\App\Console\Application\Hook(); +$app->setHook('pre-commit'); +$app->setConfigFile($config); +$app->run(); -##################################################################################################### - -EXIT_STATUS=0 - -NNTMUX=`pwd` -HOOK_DIR=/build/git-hooks -GIT=/.git/hooks -PC=/pre-commit - -# Strip off the current directory path if we are run from in the git-hooks directory. -PROJECT=${NNTMUX%${HOOK_DIR}} -HOOKS=${PROJECT}${HOOK_DIR} -FILE_LIST=${HOOKS}/git_hook_list.txt - -# stash any unstaged changes -# git stash -q --keep-index - -if [ -e ${FILE_LIST} ] -then - rm ${FILE_LIST} -fi -touch ${FILE_LIST} - -for FILE in `git diff-index --cached --name-only --diff-filter=AM ${AGAINST}` -do - echo ${PROJECT}/${FILE} >> ${FILE_LIST} -done - -EXIT_STATUS=$? - -if [ -e ${FILE_LIST} ] -then - rm ${FILE_LIST} -fi - -if [ ${EXIT_STATUS} -gt 0 ] -then - exit ${EXIT_STATUS} -fi - -# If there are whitespace errors, print the offending file names and fail. -#exec git diff-index --check --cached ${AGAINST} -- -# Remove trailing white-space in commits. -${HOOKS}/white-space-removal - -# unstash the saved stuff -# git stash pop -q diff --git a/captainhook.json b/captainhook.json new file mode 100644 index 000000000..e7b8243d7 --- /dev/null +++ b/captainhook.json @@ -0,0 +1,50 @@ +{ + "commit-msg": { + "enabled": true, + "actions": [ + { + "action": "\\CaptainHook\\App\\Hook\\Message\\Action\\Beams", + "options": { + "subjectLength": 50, + "bodyLineLength": 72 + }, + "conditions": [] + } + ] + }, + "pre-push": { + "enabled": false, + "actions": [] + }, + "pre-commit": { + "enabled": true, + "actions": [ + { + "action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting", + "options": [], + "conditions": [] + }, + { + "action": "vendor/bin/php-cs-fixer fix", + "options": [], + "conditions": [] + } + ] + }, + "prepare-commit-msg": { + "enabled": false, + "actions": [] + }, + "post-commit": { + "enabled": false, + "actions": [] + }, + "post-merge": { + "enabled": false, + "actions": [] + }, + "post-checkout": { + "enabled": false, + "actions": [] + } +} diff --git a/composer.json b/composer.json index d83e790f7..7b15d7b91 100755 --- a/composer.json +++ b/composer.json @@ -160,6 +160,8 @@ "barryvdh/laravel-debugbar": "^3.1", "barryvdh/laravel-ide-helper": "^2.4", "beyondcode/laravel-dump-server": "^1.0", + "captainhook/captainhook": "^4.4", + "captainhook/plugin-composer": "^4.0", "filp/whoops": "~2.0", "friendsofphp/php-cs-fixer": "^2.14", "fzaninotto/faker": "~1.4", @@ -186,8 +188,7 @@ ], "post-update-cmd": [ "Blacklight\\build\\ComposerScripts::postUpdate", - "@php artisan ide-helper:generate --ansi", - "@php artisan ide-helper:meta --ansi" + "@php artisan ide-helper:generate --ansi" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", diff --git a/composer.lock b/composer.lock index 6a413b376..a36818417 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a6818f464a209bafe68554b05a963cee", + "content-hash": "344580b9adfd4f74a476559fa23a6823", "packages": [ { "name": "aharen/omdbapi", @@ -8790,6 +8790,126 @@ ], "time": "2018-10-04T07:22:24+00:00" }, + { + "name": "captainhook/captainhook", + "version": "4.4.1", + "source": { + "type": "git", + "url": "https://github.com/CaptainHookPhp/captainhook.git", + "reference": "08139dedb95adc5c3a557ca5519e26f17aec6a49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/CaptainHookPhp/captainhook/zipball/08139dedb95adc5c3a557ca5519e26f17aec6a49", + "reference": "08139dedb95adc5c3a557ca5519e26f17aec6a49", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "ext-spl": "*", + "php": "^7.1", + "sebastianfeldmann/cli": "^3.0", + "sebastianfeldmann/git": "^2.2", + "symfony/console": ">=2.7" + }, + "replace": { + "sebastianfeldmann/captainhook": "*" + }, + "require-dev": { + "composer/composer": "~1", + "phpunit/phpunit": "^7.0" + }, + "bin": [ + "captainhook", + "captainhook-run" + ], + "type": "library", + "extra": { + "captainhook-config": "captainhook.json", + "captainhook-git-dir": ".git", + "branch-alias": { + "dev-master": "4.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "CaptainHook\\App\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP git hook manager", + "homepage": "https://github.com/captainhookphp/captainhook", + "keywords": [ + "commit-msg", + "git", + "hooks", + "pre-commit", + "pre-push", + "prepare-commit-msg" + ], + "time": "2019-07-15T21:15:26+00:00" + }, + { + "name": "captainhook/plugin-composer", + "version": "4.0.0", + "source": { + "type": "git", + "url": "https://github.com/CaptainHookPhp/plugin-composer.git", + "reference": "61b6c505e0e6855e7ad653f9efe0ae81304340e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/CaptainHookPhp/plugin-composer/zipball/61b6c505e0e6855e7ad653f9efe0ae81304340e0", + "reference": "61b6c505e0e6855e7ad653f9efe0ae81304340e0", + "shasum": "" + }, + "require": { + "captainhook/captainhook": "^4.0", + "composer-plugin-api": "^1.1", + "php": "^7.1" + }, + "require-dev": { + "composer/composer": "*" + }, + "type": "composer-plugin", + "extra": { + "class": "CaptainHook\\Plugin\\Composer\\ComposerPlugin", + "branch-alias": { + "dev-fluffy_hedgehog": "5.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "CaptainHook\\Plugin\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Heigl", + "email": "andreas@heigl.org" + }, + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "Composer-Plugin handling your git-hooks", + "time": "2019-01-10T19:29:52+00:00" + }, { "name": "composer/composer", "version": "1.8.6", @@ -12103,6 +12223,99 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, + { + "name": "sebastianfeldmann/cli", + "version": "3.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianfeldmann/cli.git", + "reference": "fbd21f4d2b7978cd7e79432726070dd2ee04cce5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianfeldmann/cli/zipball/fbd21f4d2b7978cd7e79432726070dd2ee04cce5", + "reference": "fbd21f4d2b7978cd7e79432726070dd2ee04cce5", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "SebastianFeldmann\\Cli\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP cli helper classes", + "homepage": "https://github.com/sebastianfeldmann/cli", + "keywords": [ + "cli" + ], + "time": "2019-06-17T22:31:05+00:00" + }, + { + "name": "sebastianfeldmann/git", + "version": "2.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianfeldmann/git.git", + "reference": "cc6190a13827b14307d2ba8595e720d6df883486" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/cc6190a13827b14307d2ba8595e720d6df883486", + "reference": "cc6190a13827b14307d2ba8595e720d6df883486", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.1", + "sebastianfeldmann/cli": "^3.0.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "SebastianFeldmann\\Git\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "PHP git wrapper", + "homepage": "https://github.com/sebastianfeldmann/git", + "keywords": [ + "git" + ], + "time": "2019-06-12T23:35:18+00:00" + }, { "name": "seld/jsonlint", "version": "1.7.1",