Spaces:
Sleeping
Sleeping
# Sync script for pushing to both Hugging Face and Azure DevOps repositories | |
# Usage: ./sync_repos.sh [commit_message] | |
set -e # Exit on any error | |
# Colors for output | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' # No Color | |
echo -e "${GREEN}π Starting repository sync...${NC}" | |
# Check if we're in a git repository | |
if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
echo -e "${RED}β Error: Not in a git repository${NC}" | |
exit 1 | |
fi | |
# Check for uncommitted changes | |
if ! git diff-index --quiet HEAD --; then | |
echo -e "${YELLOW}β οΈ You have uncommitted changes. Please commit them first.${NC}" | |
echo -e "${YELLOW} Run: git add . && git commit -m \"your message\"${NC}" | |
exit 1 | |
fi | |
# Get commit message from argument or use default | |
COMMIT_MSG=${1:-"Auto-sync: $(date '+%Y-%m-%d %H:%M:%S')"} | |
echo -e "${GREEN}π Commit message: ${COMMIT_MSG}${NC}" | |
# Add all changes and commit | |
echo -e "${GREEN}π¦ Adding and committing changes...${NC}" | |
git add . | |
git commit -m "$COMMIT_MSG" | |
# Push to Hugging Face (origin) | |
echo -e "${GREEN}π Pushing to Hugging Face (origin)...${NC}" | |
if git push origin main; then | |
echo -e "${GREEN}β Successfully pushed to Hugging Face${NC}" | |
else | |
echo -e "${RED}β Failed to push to Hugging Face${NC}" | |
exit 1 | |
fi | |
# Push to Azure DevOps (azure) | |
echo -e "${GREEN}π Pushing to Azure DevOps (azure)...${NC}" | |
if git push azure main; then | |
echo -e "${GREEN}β Successfully pushed to Azure DevOps${NC}" | |
else | |
echo -e "${YELLOW}β οΈ Failed to push to Azure DevOps, trying force push...${NC}" | |
if git push azure main --force; then | |
echo -e "${GREEN}β Successfully force pushed to Azure DevOps${NC}" | |
else | |
echo -e "${RED}β Failed to push to Azure DevOps${NC}" | |
exit 1 | |
fi | |
fi | |
echo -e "${GREEN}π Repository sync completed successfully!${NC}" | |
echo -e "${GREEN}π Remotes configured:${NC}" | |
git remote -v |