From 18d8f596733002a7e7050ea9628188448b753624 Mon Sep 17 00:00:00 2001 From: ruberoid Date: Thu, 16 Oct 2025 17:52:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B0=D0=B1=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D0=B0=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=D0=B0=20=D1=81=D1=83=D0=B1?= =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5=D0=B9.=20#7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commit-all.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 commit-all.sh diff --git a/commit-all.sh b/commit-all.sh new file mode 100755 index 0000000..2179380 --- /dev/null +++ b/commit-all.sh @@ -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