This commit is contained in:
merith-tk 2024-11-16 16:37:10 -08:00
commit 52ec89eb9a
6 changed files with 154 additions and 0 deletions

33
.scripts/lfs.sh Normal file
View file

@ -0,0 +1,33 @@
#!/bin/bash
# Set the size threshold in bytes (e.g., 10MB = 10 * 1024 * 1024)
THRESHOLD=$((10 * 1024 * 1024))
# Ensure Git LFS is initialized
git lfs install --skip-smudge
# Find large files in the current commit and throughout history
echo "Identifying large files exceeding $((THRESHOLD / 1024 / 1024))MB..."
large_files=$(find . -type f -size +${THRESHOLD}c ! -path "./.git/*")
if [ -z "$large_files" ]; then
echo "No files larger than $((THRESHOLD / 1024 / 1024))MB found."
exit 0
fi
# Track large files with Git LFS
for file in $large_files; do
if git check-ignore -q "$file"; then
continue
fi
echo "Tracking large file with Git LFS: $file"
git rm --cached "$file" >/dev/null 2>&1 ## Untrack the file from git
echo "[LFS]" $(git lfs track "$file") ## Track the file with git-lfs
done
# Add changes to .gitattributes
if [ -f .gitattributes ]; then
git add .gitattributes
else
echo "No .gitattributes file found; no changes made."
fi

View file

@ -0,0 +1,16 @@
#!/bin/sh
# File: /e:/Workspace/Fmodel/Exports/.scripts/setup-precommit.sh
# Create the .git/hooks directory if it doesn't exist
mkdir -p .git/hooks
# Write the pre-commit hook script
cat <<'EOF' >.git/hooks/pre-commit
#!/bin/sh
sh ./.scripts/lfs.sh
EOF
# Make the pre-commit hook script executable
chmod +x .git/hooks/pre-commit
echo "Pre-commit hook has been set up to run 'sh ./.scripts/lfs.sh'"