mirror of
https://github.com/sasjs/core.git
synced 2026-01-03 15:40:05 +00:00
30 lines
941 B
Bash
Executable File
30 lines
941 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Ensure lint is passing
|
|
LINT=`sasjs lint`
|
|
if [[ "$LINT" != *"All matched files use @sasjs/lint code style!" ]]; then
|
|
echo "$LINT"
|
|
echo "To commit in spite of these warnings, use the -n parameter."
|
|
exit 1
|
|
fi
|
|
|
|
# Avoid commits to the master branch
|
|
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
|
|
|
if [[ "$BRANCH" =~ ^(master|main|develop)$ ]]; then
|
|
echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?"
|
|
echo "If so, commit with -n to bypass the pre-commit hook."
|
|
exit 1
|
|
fi
|
|
|
|
## Avoid large commits
|
|
# https://www.backblaze.com/blog/how-many-bytes-are-in-a-megabyte-really/
|
|
size_limit=$((2 * 2**20)) # 2mbs
|
|
# https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---disk-usage
|
|
commit_size=$(git rev-list --disk-usage HEAD^..HEAD)
|
|
test "$commit_size" -lt "$size_limit" || (
|
|
echo "Commit size is too large: $commit_size > $size_limit"
|
|
echo "Force commit using --no-verify"
|
|
exit 1
|
|
)
|