- Moved tasmota_manager_refactor_notes.md to docs/REFACTORING_NOTES.md - Moved migrate_to_refactored.py to docs/ for future reference - Moved GitWorkflowRefactor.sh to docs/ for future reference
96 lines
2.4 KiB
Bash
96 lines
2.4 KiB
Bash
|
|
#!/bin/bash
|
|
# Git workflow script for refactoring
|
|
|
|
echo "TasmotaManager Refactoring - Git Workflow"
|
|
echo "=========================================="
|
|
|
|
# Check if we're in a git repository
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
echo "Error: Not a git repository"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for uncommitted changes
|
|
if ! git diff-index --quiet HEAD --; then
|
|
echo "Warning: You have uncommitted changes"
|
|
echo ""
|
|
git status --short
|
|
echo ""
|
|
read -p "Do you want to commit these first? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
git add -A
|
|
read -p "Enter commit message: " commit_msg
|
|
git commit -m "$commit_msg"
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "Step 1: Creating backup branch..."
|
|
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
backup_branch="${current_branch}-pre-refactor-$(date +%Y%m%d)"
|
|
git branch "$backup_branch"
|
|
echo "Created backup branch: $backup_branch"
|
|
|
|
echo ""
|
|
echo "Step 2: Running migration (dry run)..."
|
|
python3 migrate_to_refactored.py --dry-run
|
|
|
|
echo ""
|
|
read -p "Proceed with migration? (y/n) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Migration cancelled"
|
|
exit 0
|
|
fi
|
|
|
|
echo ""
|
|
echo "Step 3: Running migration..."
|
|
python3 migrate_to_refactored.py
|
|
|
|
echo ""
|
|
echo "Step 4: Verifying refactoring..."
|
|
if ! python3 verify_refactoring.py; then
|
|
echo ""
|
|
echo "Verification failed. Please review the errors."
|
|
echo "You can restore from backup branch: git checkout $backup_branch"
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Step 5: Adding files to git..."
|
|
git add -A
|
|
|
|
echo ""
|
|
echo "Step 6: Showing changes..."
|
|
git status
|
|
|
|
echo ""
|
|
echo "Step 7: Committing refactoring..."
|
|
git commit -m "Refactor: Split TasmotaManager into modular structure
|
|
|
|
- Created modular Python files (main, utils, discovery, etc.)
|
|
- Moved documentation files to docs/
|
|
- Moved data files to data/
|
|
- Removed old monolithic TasmotaManager.py
|
|
- Updated .gitignore and pyproject.toml
|
|
- All functionality preserved, command-line interface unchanged
|
|
|
|
Version: 2.0.0
|
|
"
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Refactoring complete!"
|
|
echo ""
|
|
echo "Backup branch created: $backup_branch"
|
|
echo "Current branch: $current_branch"
|
|
echo ""
|
|
echo "To push changes:"
|
|
echo " git push origin $current_branch"
|
|
echo ""
|
|
echo "To restore from backup if needed:"
|
|
echo " git checkout $backup_branch"
|
|
echo "=========================================="
|