Skip to content

Commit

Permalink
refactoring the cleanup of the plugin repository when having git errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pipiche38 committed Dec 19, 2024
1 parent 1aa957a commit 4ae4e87
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 25 deletions.
19 changes: 0 additions & 19 deletions Tools/big-clean-git.sh

This file was deleted.

6 changes: 0 additions & 6 deletions Tools/clean-git.sh

This file was deleted.

50 changes: 50 additions & 0 deletions Tools/cleaning-repository.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

# This script performs a cleanup in the local repository to allow a git pull without issues.

# Ensure the script is run from the correct directory
if [ ! -d ".git" ]; then
echo "This script must be run from the root of the git repository."
exit 1
fi

# Warning message
echo "WARNING: This script will remove all local changes and reset the repository."
echo "If you have made any local updates, they will be removed."
read -p "Do you want to continue? (YES/no): " choice

if [ "$choice" != "YES" ]; then
echo "Operation cancelled."
exit 0
fi

echo ""
echo "Removing directories tracked by git, except Data, Conf, and OTAFirmware..."
# Remove directories tracked by git, except Data and Conf
for dir in $(git ls-tree -d --name-only HEAD); do
if [ "$dir" != "Data" ] && [ "$dir" != "Conf" ] && [ "$dir" != "OTAFirmware" ]; then
echo "Removing $dir..."
rm -rf "$dir"
fi
done

echo "Resetting the repository..."
git reset --hard

echo "Pulling the latest changes from the repository..."
git pull

echo ""
echo "Cleanup and update process completed."

echo ""
echo "Repository status:"
git status

echo ""
echo "Current branch:"
git branch --show-current

echo ""
echo "Latest commits:"
git log -n 5 --oneline

0 comments on commit 4ae4e87

Please sign in to comment.