Auto-commit before update (2026-03-28 16:47)
This commit is contained in:
parent
2f06e9bdab
commit
9a6337e381
1 changed files with 93 additions and 0 deletions
93
update.sh
Executable file
93
update.sh
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
|
||||
# update.sh - Unzips a new NavidromePlayer.zip and replaces all project files
|
||||
# while preserving your .git history.
|
||||
#
|
||||
# Usage: Place this script in your NavidromePlayer/ root directory.
|
||||
# Drop the new NavidromePlayer.zip in the SAME directory.
|
||||
# Then run: ./update.sh
|
||||
#
|
||||
# It will:
|
||||
# 1. Auto-commit any uncommitted changes
|
||||
# 2. Delete all project files (keeps .git and this script)
|
||||
# 3. Unzip the new version
|
||||
# 4. Show you what changed
|
||||
# 5. Commit with the zip's git message or a default
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
ZIP_FILE="NavidromePlayer.zip"
|
||||
|
||||
# Check zip exists
|
||||
if [ ! -f "$ZIP_FILE" ]; then
|
||||
echo "❌ $ZIP_FILE not found in $(pwd)"
|
||||
echo " Drop the zip file here and run again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check we're in a git repo
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "❌ No .git directory found. Run this from your NavidromePlayer repo root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Updating NavidromePlayer from $ZIP_FILE"
|
||||
echo ""
|
||||
|
||||
# Step 1: Auto-commit any uncommitted work
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "💾 Committing your uncommitted changes first..."
|
||||
git add -A
|
||||
git commit -m "Auto-commit before update ($(date '+%Y-%m-%d %H:%M'))"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Step 2: Delete everything except .git, this script, and the zip
|
||||
echo "🗑 Removing old project files..."
|
||||
find . -maxdepth 1 \
|
||||
-not -name '.' \
|
||||
-not -name '.git' \
|
||||
-not -name "$ZIP_FILE" \
|
||||
-not -name 'update.sh' \
|
||||
-exec rm -rf {} \;
|
||||
|
||||
# Step 3: Unzip
|
||||
echo "📂 Extracting $ZIP_FILE..."
|
||||
unzip -q -o "$ZIP_FILE"
|
||||
|
||||
# Move files out of the NavidromePlayer/ wrapper folder
|
||||
if [ -d "NavidromePlayer" ]; then
|
||||
# Use rsync to handle dotfiles properly
|
||||
shopt -s dotglob
|
||||
mv NavidromePlayer/* . 2>/dev/null || true
|
||||
shopt -u dotglob
|
||||
rmdir NavidromePlayer 2>/dev/null || rm -rf NavidromePlayer
|
||||
fi
|
||||
|
||||
# Step 4: Show diff
|
||||
echo ""
|
||||
echo "📊 Changes:"
|
||||
git add -A
|
||||
git diff --cached --stat
|
||||
echo ""
|
||||
|
||||
# Step 5: Count changes
|
||||
CHANGED=$(git diff --cached --numstat | wc -l | tr -d ' ')
|
||||
|
||||
if [ "$CHANGED" -eq "0" ]; then
|
||||
echo "✅ No changes - you're already up to date."
|
||||
git reset HEAD . > /dev/null 2>&1
|
||||
else
|
||||
# Commit
|
||||
echo "💾 Committing $CHANGED changed files..."
|
||||
git commit -m "Update from NavidromePlayer.zip ($(date '+%Y-%m-%d %H:%M'))"
|
||||
echo ""
|
||||
echo "✅ Done! Latest commits:"
|
||||
git log --oneline -5
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🔨 Don't forget to run: ./generate.sh"
|
||||
Loading…
Reference in a new issue