Spaces:
Sleeping
Sleeping
Commit Β·
90998a3
1
Parent(s): 3319ace
Add sync script for dual repository management
Browse files- sync_repos.sh +64 -0
sync_repos.sh
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Sync script for pushing to both Hugging Face and Azure DevOps repositories
|
| 4 |
+
# Usage: ./sync_repos.sh [commit_message]
|
| 5 |
+
|
| 6 |
+
set -e # Exit on any error
|
| 7 |
+
|
| 8 |
+
# Colors for output
|
| 9 |
+
RED='\033[0;31m'
|
| 10 |
+
GREEN='\033[0;32m'
|
| 11 |
+
YELLOW='\033[1;33m'
|
| 12 |
+
NC='\033[0m' # No Color
|
| 13 |
+
|
| 14 |
+
echo -e "${GREEN}π Starting repository sync...${NC}"
|
| 15 |
+
|
| 16 |
+
# Check if we're in a git repository
|
| 17 |
+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
| 18 |
+
echo -e "${RED}β Error: Not in a git repository${NC}"
|
| 19 |
+
exit 1
|
| 20 |
+
fi
|
| 21 |
+
|
| 22 |
+
# Check for uncommitted changes
|
| 23 |
+
if ! git diff-index --quiet HEAD --; then
|
| 24 |
+
echo -e "${YELLOW}β οΈ You have uncommitted changes. Please commit them first.${NC}"
|
| 25 |
+
echo -e "${YELLOW} Run: git add . && git commit -m \"your message\"${NC}"
|
| 26 |
+
exit 1
|
| 27 |
+
fi
|
| 28 |
+
|
| 29 |
+
# Get commit message from argument or use default
|
| 30 |
+
COMMIT_MSG=${1:-"Auto-sync: $(date '+%Y-%m-%d %H:%M:%S')"}
|
| 31 |
+
|
| 32 |
+
echo -e "${GREEN}π Commit message: ${COMMIT_MSG}${NC}"
|
| 33 |
+
|
| 34 |
+
# Add all changes and commit
|
| 35 |
+
echo -e "${GREEN}π¦ Adding and committing changes...${NC}"
|
| 36 |
+
git add .
|
| 37 |
+
git commit -m "$COMMIT_MSG"
|
| 38 |
+
|
| 39 |
+
# Push to Hugging Face (origin)
|
| 40 |
+
echo -e "${GREEN}π Pushing to Hugging Face (origin)...${NC}"
|
| 41 |
+
if git push origin main; then
|
| 42 |
+
echo -e "${GREEN}β
Successfully pushed to Hugging Face${NC}"
|
| 43 |
+
else
|
| 44 |
+
echo -e "${RED}β Failed to push to Hugging Face${NC}"
|
| 45 |
+
exit 1
|
| 46 |
+
fi
|
| 47 |
+
|
| 48 |
+
# Push to Azure DevOps (azure)
|
| 49 |
+
echo -e "${GREEN}π Pushing to Azure DevOps (azure)...${NC}"
|
| 50 |
+
if git push azure main; then
|
| 51 |
+
echo -e "${GREEN}β
Successfully pushed to Azure DevOps${NC}"
|
| 52 |
+
else
|
| 53 |
+
echo -e "${YELLOW}β οΈ Failed to push to Azure DevOps, trying force push...${NC}"
|
| 54 |
+
if git push azure main --force; then
|
| 55 |
+
echo -e "${GREEN}β
Successfully force pushed to Azure DevOps${NC}"
|
| 56 |
+
else
|
| 57 |
+
echo -e "${RED}β Failed to push to Azure DevOps${NC}"
|
| 58 |
+
exit 1
|
| 59 |
+
fi
|
| 60 |
+
fi
|
| 61 |
+
|
| 62 |
+
echo -e "${GREEN}π Repository sync completed successfully!${NC}"
|
| 63 |
+
echo -e "${GREEN}π Remotes configured:${NC}"
|
| 64 |
+
git remote -v
|