Skip to content

Instantly share code, notes, and snippets.

@ManotLuijiu
Last active April 19, 2025 17:55
Show Gist options
  • Save ManotLuijiu/5988bef6fcd6dd78b840e5f751a099cc to your computer and use it in GitHub Desktop.
Save ManotLuijiu/5988bef6fcd6dd78b840e5f751a099cc to your computer and use it in GitHub Desktop.
#!/bin/bash
for app in "${apps_with_git[@]}"; do
echo "Checking branch in $app..."
git -C "$app" branch --show-current
done
#!/bin/bash
apps_with_git=()
for app in apps/*; do
if [ -d "$app/.git" ]; then
apps_with_git+=("$app")
echo "===== $app ====="
git -C "$app" status --short
echo
fi
done
#!/bin/bash
echo "πŸš€ Auto-committing and pushing all changes..."
# List of apps you OWN and want to auto-commit/push for example
OWNED_APPS=("thai_google_sheets" "thai_business_suite" "translation_tools")
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
for app in apps/*; do
app_name=$(basename "$app")
# Only proceed if it's in the list of owned apps
if [[ " ${OWNED_APPS[@]} " =~ " ${app_name} " ]]; then
if [ -d "$app/.git" ]; then
echo
echo "===== $app ====="
cd "$app"
if [ -n "$(git status --porcelain)" ]; then
echo "πŸ“¦ Changes found. Committing and pushing $app_name..."
git add .
git commit -m "chore: Auto-commit on $timestamp" --no-verify
echo "πŸ”„ Pushing changes to remote..."
git push origin "$(git rev-parse --abbrev-ref HEAD)"
else
echo "βœ… No changes $app_name is clean, nothing to commit"
fi
cd - >/dev/null
fi
else
echo "===== Skipping $app_name (not owned) ====="
fi
done
echo
echo "βœ… All done!"
echo "πŸš€ Auto-committing and pushing all changes..."
#!/bin/bash
echo "πŸš€ Auto-committing and pushing all changes..."
# List of apps you OWN and want to auto-commit/push for example
OWNED_APPS=("thai_google_sheets" "thai_business_suite" "translation_tools")
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
for app in apps/*; do
app_name=$(basename "$app")
# Only proceed if it's in the list of owned apps
if [[ " ${OWNED_APPS[@]} " =~ " ${app_name} " ]]; then
if [ -d "$app/.git" ]; then
echo
echo "===== $app ====="
cd "$app"
if [ -n "$(git status --porcelain)" ]; then
echo "πŸ“¦ Changes found. Committing and pushing $app_name..."
git add .
git commit -m "chore: Auto-commit on $timestamp"
echo "πŸ”„ Pushing changes to remote..."
git push origin "$(git rev-parse --abbrev-ref HEAD)"
else
echo "βœ… No changes $app_name is clean, nothing to commit"
fi
cd - >/dev/null
fi
else
echo "===== Skipping $app_name (not owned) ====="
fi
done
echo
echo "βœ… All done!"
echo "πŸš€ Auto-committing and pushing all changes..."
#!/bin/bash
echo "πŸ”„ Fixing remotes and pulling latest changes for all apps..."
cd ~/frappe-bench/apps
for app in */; do
if [ -d "$app/.git" ]; then
echo
echo "===== $app ====="
cd "$app"
echo "πŸ” Checking git remotes..."
git remote -v
# Add origin if missing
if ! git remote | grep -q "^origin$"; then
if git remote | grep -q "^upstream$"; then
upstream_url=$(git remote get-url upstream)
echo "πŸ“Œ Adding 'origin' pointing to '$upstream_url'"
git remote add origin "$upstream_url"
else
echo "⚠️ No upstream found. Skipping $app"
cd ..
continue
fi
else
echo "βœ… 'origin' already set."
fi
# Pull latest changes from the current branch
branch=$(git rev-parse --abbrev-ref HEAD)
echo "πŸ“₯ Pulling latest from origin/$branch..."
git pull origin "$branch"
echo "βœ… Done with $app"
echo "-------------------------"
cd ..
fi
done
echo
echo "πŸŽ‰ All apps updated successfully!"
#!/bin/bash
echo "πŸ” Checking all Git-enabled apps in ./apps..."
apps_with_git=()
for app in apps/*; do
if [ -d "$app/.git" ]; then
apps_with_git+=("$app")
echo
echo "===== $app ====="
# Show current branch
branch=$(git -C "$app" rev-parse --abbrev-ref HEAD)
echo "πŸ“¦ Branch: $branch"
# Show uncommitted changes
status=$(git -C "$app" status --short)
if [ -n "$status" ]; then
echo "πŸ“ Uncommitted Changes:"
echo "$status"
else
echo "βœ… Clean working tree"
fi
# Show if ahead/behind
git -C "$app" remote update >/dev/null 2>&1
ahead_behind=$(git -C "$app" status -sb | grep '\[.*\]')
if [ -n "$ahead_behind" ]; then
echo "πŸ” Sync Status: $ahead_behind"
fi
# Show latest commit
last_commit=$(git -C "$app" log -1 --pretty=format:"%h %s (%cr)")
echo "πŸ•’ Last Commit: $last_commit"
fi
done
echo
echo "βœ… Done. Checked ${#apps_with_git[@]} Git-enabled apps."
@ManotLuijiu
Copy link
Author

If you're using pre-commit hooks (like Husky with lint-staged), use the --no-verify flag in the auto-commit-no-verify-push.sh script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment