مدير Hooks GIT لـ Node.js و Ruby و Python والعديد من أنواع المشاريع الأخرى.
الوثائق
اقرأ منشور المقدمة
مع GO (> = 1.23):
go install github.com/evilmartians/lefthook@latestمع NPM :
npm install lefthook --save-devلروبي :
gem install lefthookلبيثون :
pip install lefthookدليل التثبيت مع المزيد من الطرق لتثبيت Lefthook: APT ، Brew ، Winget ، وغيرها.
قم بتكوين السنانير الخاصة بك ، وتثبيتها مرة واحدة ونسيها: اعتمد على السحر تحتها.
# Configure your hooks
vim lefthook.yml
# Install them to the git project
lefthook install
# Enjoy your work with git
git add -A && git commit -m ' ... ' lefthook.yml .يمنحك المزيد من السرعة. مستندات
pre-push :
parallel : trueإذا كنت تريد قائمتك الخاصة. أمثلة مخصصة ومبتكرة.
pre-commit :
commands :
frontend-linter :
run : yarn eslint {staged_files}
backend-linter :
run : bundle exec rubocop --force-exclusion {all_files}
frontend-style :
files : git diff --name-only HEAD @{push}
run : yarn stylelint {files}إذا كنت ترغب في تصفية قائمة الملفات. يمكن أن تجد المزيد من أمثلة نمط الكرة الأرضية هنا.
pre-commit :
commands :
backend-linter :
glob : " *.rb " # glob filter
exclude : ' (^|/)(application|routes).rb$ ' # regexp filter
run : bundle exec rubocop --force-exclusion {all_files}إذا كنت ترغب في تنفيذ الأوامر في مسار نسبي
pre-commit :
commands :
backend-linter :
root : " api/ " # Careful to have only trailing slash
glob : " *.rb " # glob filter
run : bundle exec rubocop {all_files}إذا لم تكن أوامر OnLine كافية ، فيمكنك تنفيذ الملفات. مستندات
commit-msg :
scripts :
" template_checker " :
runner : bashإذا كنت تريد التحكم في مجموعة من الأوامر. مستندات
pre-push :
commands :
packages-audit :
tags :
- frontend
- linters
run : yarn lint
gems-audit :
tags :
- backend
- security
run : bundle auditإذا كنت في بيئة Docker. مستندات
pre-commit :
scripts :
" good_job.js " :
runner : docker run -it --rm <container_id_or_name> {cmd}إذا كنت مطورًا للواجهة/الواجهة الخلفية وترغب في تخطي الأوامر غير الضرورية أو تجاوز شيء ما في Docker. مستندات
# lefthook-local.yml
pre-push :
exclude_tags :
- frontend
commands :
packages-audit :
skip : trueإذا كنت ترغب في تشغيل مجموعة Hooks مباشرة.
$ lefthook run pre-commitإذا كنت ترغب في تشغيل مجموعة محددة من الأوامر مباشرة.
fixer :
commands :
ruby-fixer :
run : bundle exec rubocop --force-exclusion --safe-auto-correct {staged_files}
js-fixer :
run : yarn eslint --fix {staged_files} $ lefthook run fixerيمكنك التحكم في ما يطبعه Lefthook مع خيار الإخراج.
output :
- execution
- failureتحقق من الأمثلة