Skip to content

Instantly share code, notes, and snippets.

View slnc's full-sized avatar

Juan Alonso slnc

View GitHub Profile
@damienrg
damienrg / git-multi-hook-template
Last active November 24, 2023 14:22
Script to allow multi hooks per hook type for git
#!/usr/bin/env bash
# Allow multiple hooks.
#
# To use it copy this script with executable permission in ".git/hooks/hook-name"
# where hook-name is the name of the hook (see man githooks to know available hooks).
# Then place your scripts with executable permission in ".git/hooks/hook-name.d/".
hook_type=${BASH_SOURCE##*/}
@edisonywh
edisonywh / pre-commit
Last active April 15, 2024 22:58
Run Rubocop in Git's pre-commit hook
```
#!/bin/sh
echo "\nRunning rubocop 🚓 💨 💨 💨\n"
declare -a ERRORS=()
for file in $(git diff --cached --name-only | grep -E '.rb')
do
ERRORS+=("$(rubocop $file | grep -e 'C:' -e 'E:')")
done