1 changed files with 67 additions and 0 deletions
@ -0,0 +1,67 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# TimeSafari Generated Assets Purge Script |
||||
|
# Removes generated Android assets and resources from git history |
||||
|
# Author: Matthew Raymer |
||||
|
|
||||
|
set -e |
||||
|
|
||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" |
||||
|
|
||||
|
echo "=== TimeSafari Generated Assets Purge ===" |
||||
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Starting git history cleanup" |
||||
|
|
||||
|
# Check if we're in a git repository |
||||
|
if [ ! -d ".git" ]; then |
||||
|
echo "[ERROR] Not in a git repository. Please run this script from the project root." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# Check if we have uncommitted changes |
||||
|
if [ -n "$(git status --porcelain)" ]; then |
||||
|
echo "[ERROR] You have uncommitted changes. Please commit or stash them first." |
||||
|
echo "Current status:" |
||||
|
git status --short |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# Create backup branch |
||||
|
BACKUP_BRANCH="backup-before-asset-purge-$(date +%Y%m%d-%H%M%S)" |
||||
|
echo "[INFO] Creating backup branch: $BACKUP_BRANCH" |
||||
|
git branch "$BACKUP_BRANCH" |
||||
|
|
||||
|
echo "[INFO] Starting git filter-branch to remove generated assets..." |
||||
|
|
||||
|
# Use git filter-branch to remove the directories from history |
||||
|
git filter-branch --force --index-filter ' |
||||
|
# Remove generated Android assets directory |
||||
|
git rm -rf --cached --ignore-unmatch android/app/src/main/assets/public/ 2>/dev/null || true |
||||
|
|
||||
|
# Remove generated Android resources (but keep config files) |
||||
|
git rm -rf --cached --ignore-unmatch android/app/src/main/res/drawable*/ 2>/dev/null || true |
||||
|
git rm -rf --cached --ignore-unmatch android/app/src/main/res/mipmap*/ 2>/dev/null || true |
||||
|
git rm -rf --cached --ignore-unmatch android/app/src/main/res/values/ic_launcher_background.xml 2>/dev/null || true |
||||
|
|
||||
|
# Keep configuration files |
||||
|
git add android/app/src/main/res/values/strings.xml 2>/dev/null || true |
||||
|
git add android/app/src/main/res/values/styles.xml 2>/dev/null || true |
||||
|
git add android/app/src/main/res/layout/activity_main.xml 2>/dev/null || true |
||||
|
git add android/app/src/main/res/xml/config.xml 2>/dev/null || true |
||||
|
git add android/app/src/main/res/xml/file_paths.xml 2>/dev/null || true |
||||
|
' --prune-empty --tag-name-filter cat -- --all |
||||
|
|
||||
|
echo "[INFO] Cleaning up git filter-branch temporary files..." |
||||
|
rm -rf .git/refs/original/ |
||||
|
git reflog expire --expire=now --all |
||||
|
git gc --prune=now --aggressive |
||||
|
|
||||
|
echo "[SUCCESS] Generated assets purged from git history!" |
||||
|
echo "[INFO] Backup branch created: $BACKUP_BRANCH" |
||||
|
echo "[INFO] Repository size should be significantly reduced" |
||||
|
echo "" |
||||
|
echo "Next steps:" |
||||
|
echo "1. Test that the repository works correctly" |
||||
|
echo "2. Force push to remote: git push --force-with-lease origin <branch>" |
||||
|
echo "3. Inform team members to re-clone or reset their local repositories" |
||||
|
echo "4. Delete backup branch when confident: git branch -D $BACKUP_BRANCH" |
Loading…
Reference in new issue