Доабвил скрипт автокоммита субмодулей. #7
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
ruberoid 2025-10-16 17:52:31 +04:00
parent a280ffc9db
commit 18d8f59673

91
commit-all.sh Executable file
View File

@ -0,0 +1,91 @@
#!/bin/bash
# Check if commit message is provided
if [ -z "$1" ]; then
echo "Error: Commit message is required"
echo "Usage: ./commit-all.sh \"Your commit message\""
exit 1
fi
COMMIT_MSG="$1"
# Get list of submodules
SUBMODULES=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
if [ -z "$SUBMODULES" ]; then
echo "No submodules found in this repository"
exit 0
fi
echo "🚀 Starting commit and push for all submodules..."
echo "📝 Commit message: $COMMIT_MSG"
echo ""
# Counter for tracking results
SUCCESS_COUNT=0
FAILED_COUNT=0
SKIPPED_COUNT=0
# Iterate through each submodule
for submodule in $SUBMODULES; do
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📦 Processing submodule: $submodule"
if [ ! -d "$submodule" ]; then
echo "⚠️ Warning: Submodule directory not found, skipping..."
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
continue
fi
cd "$submodule" || {
echo "❌ Failed to enter directory $submodule"
FAILED_COUNT=$((FAILED_COUNT + 1))
cd - > /dev/null
continue
}
# Check if there are any changes
if [ -z "$(git status --porcelain)" ]; then
echo " No changes to commit, skipping..."
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
cd - > /dev/null
continue
fi
# Add all changes
echo " → git add -A"
git add -A
# Commit changes
echo " → git commit"
if git commit -m "$COMMIT_MSG"; then
# Push to main branch
echo " → git push origin main"
if git push origin main; then
echo "✅ Successfully committed and pushed"
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
else
echo "❌ Failed to push"
FAILED_COUNT=$((FAILED_COUNT + 1))
fi
else
echo "❌ Failed to commit"
FAILED_COUNT=$((FAILED_COUNT + 1))
fi
cd - > /dev/null
echo ""
done
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📊 Summary:"
echo " ✅ Success: $SUCCESS_COUNT"
echo " ❌ Failed: $FAILED_COUNT"
echo " ⏭️ Skipped: $SKIPPED_COUNT"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ $FAILED_COUNT -gt 0 ]; then
exit 1
fi
exit 0