Spaces:
Sleeping
Sleeping
File size: 1,947 Bytes
90998a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
#!/bin/bash
# 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 |