#!/usr/bin/env bash
# Push sports_platform to GitHub (origin/main) and GitLab (likelysport/sports-platform).
# Usage:
#   ./push-all.sh                 push existing commits only
#   ./push-all.sh "commit msg"    commit all changes first, then push
set -e

cd "$(dirname "$0")"

if [ -n "$1" ] && [ -n "$(git status --porcelain)" ]; then
    git add -A
    git commit -m "$1"
fi

if [ -n "$(git status --porcelain)" ]; then
    echo "You have uncommitted changes. Run: ./push-all.sh \"your commit message\""
    exit 1
fi

echo "==> Pushing to GitHub (origin main)"
git push origin main

echo "==> Pushing to GitLab (likelysport sports-platform)"
git push likelysport main:sports-platform

echo "Done."
