Files
Retribusi/pull.sh

43 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
# Script untuk pull frontend di server production
# Usage: bash pull.sh
echo "🔄 Pulling Retribusi Frontend..."
cd "$(dirname "$0")" || exit
# Cek apakah ini git repository
if [ ! -d ".git" ]; then
echo "❌ Error: Bukan git repository"
exit 1
fi
# Fix dubious ownership jika perlu
REPO_PATH=$(pwd)
if ! git config --global --get-regexp "safe.directory" | grep -q "$REPO_PATH"; then
echo "🔒 Adding safe.directory untuk fix ownership issue..."
git config --global --add safe.directory "$REPO_PATH"
fi
# Cek branch saat ini
CURRENT_BRANCH=$(git branch --show-current)
echo "📍 Current branch: $CURRENT_BRANCH"
# Stash perubahan lokal jika ada (untuk openapi.json atau file lain yang mungkin berubah)
echo "💾 Stashing local changes (if any)..."
git stash
# Pull dari origin main
echo "⬇️ Pulling from origin/main..."
git pull origin main
# Jika ada stash, coba pop (optional)
if git stash list | grep -q .; then
echo "📦 Restoring stashed changes..."
git stash pop || echo "⚠️ Warning: Ada conflict saat restore stash, silakan resolve manual"
fi
echo "✅ Pull selesai!"
echo ""
echo "📊 Status:"
git status --short