mirror of
https://github.com/taigrr/hooks.git
synced 2026-04-02 03:18:55 -07:00
initial commit
This commit is contained in:
3
post-checkout
Executable file
3
post-checkout
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
|
||||||
|
git lfs post-checkout "$@"
|
||||||
3
post-commit
Executable file
3
post-commit
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
|
||||||
|
git lfs post-commit "$@"
|
||||||
3
post-merge
Executable file
3
post-merge
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
|
||||||
|
git lfs post-merge "$@"
|
||||||
34
pre-commit
Executable file
34
pre-commit
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set +eou pipefail
|
||||||
|
size_limit=$((5 * 2**20))
|
||||||
|
# make sure we have at least 1 commit in the repo
|
||||||
|
# so we don't fail on the first commit
|
||||||
|
test "$(git rev-list --count HEAD 2>/dev/null)" -gt 1 2> /dev/null > /dev/null || exit 0
|
||||||
|
|
||||||
|
repo_root=$(git rev-parse --show-toplevel)
|
||||||
|
pushd $repo_root 2>/dev/null > /dev/null
|
||||||
|
empty_tree=$(git hash-object -t tree /dev/null)
|
||||||
|
if git rev-parse --verify HEAD > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
against=HEAD
|
||||||
|
else
|
||||||
|
against="$empty_tree"
|
||||||
|
fi
|
||||||
|
IFS='
|
||||||
|
'
|
||||||
|
hasLargeFile=false
|
||||||
|
for file in $(git diff-index --cached --name-only $against); do
|
||||||
|
file_size=$(([ ! -f $file ] && echo 0) || (ls -la $file | awk '{ print $5 }'))
|
||||||
|
if [ "$file_size" -gt "$size_limit" ]; then
|
||||||
|
echo File $file is $(( $file_size / 10**6 )) MB, which is larger than our configured limit of $(( $size_limit / 10**6 )) MB
|
||||||
|
hasLargeFile=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $hasLargeFile; then
|
||||||
|
echo Commit too large, did you add a binary file? For image assets, consider git-lfs.
|
||||||
|
popd $repo_root 2>/dev/null > /dev/null
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
popd $repo_root 2>/dev/null > /dev/null || true
|
||||||
|
gitleaks protect --verbose --redact --staged
|
||||||
31
pre-push
Executable file
31
pre-push
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# An example hook script to verify what is about to be pushed. Called by "git
|
||||||
|
# push" after it has checked the remote status, but before anything has been
|
||||||
|
# pushed. If this script exits with a non-zero status nothing will be pushed.
|
||||||
|
#
|
||||||
|
# This hook is called with the following parameters:
|
||||||
|
#
|
||||||
|
# $1 -- Name of the remote to which the push is being done
|
||||||
|
# $2 -- URL to which the push is being done
|
||||||
|
#
|
||||||
|
# If pushing without using a named remote those arguments will be equal.
|
||||||
|
#
|
||||||
|
# Information about the commits which are being pushed is supplied as lines to
|
||||||
|
# the standard input in the form:
|
||||||
|
#
|
||||||
|
# <local ref> <local oid> <remote ref> <remote oid>
|
||||||
|
#
|
||||||
|
# This sample shows how to prevent push of commits where the log message starts
|
||||||
|
# with "WIP" (work in progress).
|
||||||
|
|
||||||
|
#remote="$1"
|
||||||
|
#url="$2"
|
||||||
|
|
||||||
|
#zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
|
||||||
|
|
||||||
|
|
||||||
|
mg register >/dev/null 2> /dev/null || { echo >&2 "\nThis repository is configured for mg but 'mg' was not found on your path. Install it with go install github.com/taigrr/mg/cmd/mg@latest or remove this code from your templates in ~/.config/git/hooks.\n"; exit 2; }
|
||||||
|
|
||||||
|
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push' and your templates in ~/.config/git/hooks.\n"; exit 2; }
|
||||||
|
git lfs pre-push "$@"
|
||||||
Reference in New Issue
Block a user