Skip to content

Commit

Permalink
Add captainhook/captainhook to dev environment
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Jul 24, 2019
1 parent df255dc commit aaa4022
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 66 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
77 changes: 14 additions & 63 deletions build/git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -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
<?php
$autoLoader = __DIR__ . '/../../vendor/autoload.php';

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();

if git rev-parse --verify HEAD >/dev/null 2>&1
then
AGAINST=HEAD
else
# Initial commit: diff against an empty tree object
AGAINST=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

#####################################################################################################

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
50 changes: 50 additions & 0 deletions captainhook.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
215 changes: 214 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aaa4022

Please sign in to comment.