File sync-with-osc.sh of Package kernel-source
#!/bin/bash
# Sync script to keep git and OSC in sync
# Run this script after making changes to sync between git and OSC
set -e
echo "=== SUSE Kernel OSC/Git Sync Script ==="
# Check if we're in the right directory
if [[ ! -f "kernel-source.spec" ]]; then
echo "Error: Not in kernel-source directory"
exit 1
fi
# Check OSC status
echo "Checking OSC status..."
osc status
# Check git status
echo "Checking git status..."
git status --short
echo "Available commands:"
echo " 1) Commit git changes and push to OSC"
echo " 2) Pull OSC changes and commit to git"
echo " 3) Show differences between git and OSC"
echo " 4) Exit"
read -p "Enter choice [1-4]: " choice
case $choice in
1)
echo "=== Committing git changes to OSC ==="
read -p "Enter commit message: " message
# Add any new files in git to OSC
git ls-files --others --exclude-standard | while read file; do
if [[ -f "$file" ]] && [[ ! "$file" =~ ^\.osc/ ]] && [[ ! "$file" =~ \.git ]]; then
echo "Adding $file to OSC..."
osc add "$file" 2>/dev/null || true
fi
done
# Commit to OSC
osc commit -m "$message"
# Commit to git if needed
if [[ -n $(git status --porcelain) ]]; then
git add -A
git commit -m "$message"
fi
;;
2)
echo "=== Pulling OSC changes to git ==="
osc update
git add -A
if [[ -n $(git status --porcelain) ]]; then
git commit -m "Sync from OSC: $(date)"
fi
;;
3)
echo "=== Showing differences ==="
echo "Files in git but not in OSC:"
git ls-files | while read file; do
if [[ ! -f ".osc/$file" ]] 2>/dev/null; then
echo " $file"
fi
done
;;
4)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo "=== Sync complete ==="