Spaces:
Sleeping
Sleeping
Commit
Β·
491bebc
1
Parent(s):
90998a3
Add enhanced sync script and collaborative workflow documentation
Browse files- COLLABORATIVE_WORKFLOW.md +170 -0
- sync_repos_enhanced.sh +132 -0
COLLABORATIVE_WORKFLOW.md
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Collaborative Workflow with Dual Repositories
|
2 |
+
|
3 |
+
This project is configured to sync with both **Hugging Face** and **Azure DevOps** repositories. This guide explains how to work collaboratively with your team.
|
4 |
+
|
5 |
+
## Repository Configuration
|
6 |
+
|
7 |
+
- **Origin (Hugging Face)**: `https://huggingface.co/spaces/levalencia/docling`
|
8 |
+
- **Azure DevOps**: `https://element61.visualstudio.com/ZAS%20pati%C3%ABntvriendelijke%20brief/_git/streamlit_test_app_medicationlist`
|
9 |
+
|
10 |
+
## Recommended Workflow
|
11 |
+
|
12 |
+
### For You (Project Owner)
|
13 |
+
|
14 |
+
#### Daily Workflow
|
15 |
+
1. **Before starting work**: Run the enhanced sync script
|
16 |
+
```bash
|
17 |
+
./sync_repos_enhanced.sh
|
18 |
+
```
|
19 |
+
|
20 |
+
2. **Make your changes** and commit them
|
21 |
+
```bash
|
22 |
+
git add .
|
23 |
+
git commit -m "Your commit message"
|
24 |
+
```
|
25 |
+
|
26 |
+
3. **Sync to both repositories**
|
27 |
+
```bash
|
28 |
+
./sync_repos_enhanced.sh "Your commit message"
|
29 |
+
```
|
30 |
+
|
31 |
+
#### When Colleagues Have Made Changes
|
32 |
+
The enhanced script will automatically:
|
33 |
+
- Fetch changes from both repositories
|
34 |
+
- Merge any new commits
|
35 |
+
- Handle conflicts gracefully
|
36 |
+
- Push your changes to both repositories
|
37 |
+
|
38 |
+
### For Your Colleagues
|
39 |
+
|
40 |
+
#### Option 1: Work on Azure DevOps Only (Recommended)
|
41 |
+
Your colleagues should:
|
42 |
+
1. Clone from Azure DevOps
|
43 |
+
```bash
|
44 |
+
git clone https://element61.visualstudio.com/ZAS%20pati%C3%ABntvriendelijke%20brief/_git/streamlit_test_app_medicationlist.git
|
45 |
+
```
|
46 |
+
|
47 |
+
2. Make changes and push to Azure DevOps
|
48 |
+
```bash
|
49 |
+
git add .
|
50 |
+
git commit -m "Colleague's changes"
|
51 |
+
git push origin main
|
52 |
+
```
|
53 |
+
|
54 |
+
3. You'll sync their changes when you run the enhanced sync script
|
55 |
+
|
56 |
+
#### Option 2: Work on Both Repositories
|
57 |
+
If colleagues need access to both repositories:
|
58 |
+
1. Clone your repository
|
59 |
+
```bash
|
60 |
+
git clone https://huggingface.co/spaces/levalencia/docling.git
|
61 |
+
```
|
62 |
+
|
63 |
+
2. Add Azure DevOps as a remote
|
64 |
+
```bash
|
65 |
+
git remote add azure https://element61.visualstudio.com/ZAS%20pati%C3%ABntvriendelijke%20brief/_git/streamlit_test_app_medicationlist
|
66 |
+
```
|
67 |
+
|
68 |
+
3. Use the enhanced sync script for their changes too
|
69 |
+
|
70 |
+
## Conflict Resolution
|
71 |
+
|
72 |
+
### Scenario 1: Colleagues Work on Azure DevOps
|
73 |
+
```
|
74 |
+
Timeline:
|
75 |
+
1. You make changes β Push to both repos
|
76 |
+
2. Colleague makes changes β Push to Azure only
|
77 |
+
3. You make more changes β Try to sync
|
78 |
+
|
79 |
+
Result: Enhanced script will:
|
80 |
+
- Fetch from Azure DevOps
|
81 |
+
- Merge colleague's changes
|
82 |
+
- Push your merged changes to both repos
|
83 |
+
```
|
84 |
+
|
85 |
+
### Scenario 2: Conflicts Occur
|
86 |
+
If there are merge conflicts:
|
87 |
+
1. The script will stop and show you which files have conflicts
|
88 |
+
2. Manually resolve conflicts in the conflicted files
|
89 |
+
3. Add resolved files: `git add .`
|
90 |
+
4. Commit: `git commit -m "Resolve merge conflicts"`
|
91 |
+
5. Run the sync script again
|
92 |
+
|
93 |
+
### Scenario 3: Force Push Needed
|
94 |
+
If you need to overwrite Azure DevOps changes:
|
95 |
+
```bash
|
96 |
+
./sync_repos_enhanced.sh "Your message" --force-azure
|
97 |
+
```
|
98 |
+
|
99 |
+
β οΈ **Warning**: Only use force push when you're sure you want to overwrite Azure DevOps changes!
|
100 |
+
|
101 |
+
## Best Practices
|
102 |
+
|
103 |
+
### Communication
|
104 |
+
- **Designate a primary repository**: Decide which repo is the "source of truth"
|
105 |
+
- **Coordinate pushes**: Let team know when you're about to sync
|
106 |
+
- **Use meaningful commit messages**: Help track what changes were made
|
107 |
+
|
108 |
+
### Workflow Tips
|
109 |
+
- **Always sync before starting work**: Prevents conflicts
|
110 |
+
- **Test changes locally**: Before pushing to either repository
|
111 |
+
- **Backup important work**: Before force pushing
|
112 |
+
- **Use feature branches**: For major changes to avoid conflicts
|
113 |
+
|
114 |
+
### Repository Roles
|
115 |
+
- **Hugging Face**: Primary development and deployment
|
116 |
+
- **Azure DevOps**: Team collaboration and backup
|
117 |
+
|
118 |
+
## Troubleshooting
|
119 |
+
|
120 |
+
### Common Issues
|
121 |
+
|
122 |
+
#### "Push Rejected" Error
|
123 |
+
```bash
|
124 |
+
# Fetch and merge first
|
125 |
+
git fetch azure
|
126 |
+
git merge azure/main
|
127 |
+
|
128 |
+
# Then push
|
129 |
+
git push azure main
|
130 |
+
```
|
131 |
+
|
132 |
+
#### Merge Conflicts
|
133 |
+
```bash
|
134 |
+
# See conflicted files
|
135 |
+
git status
|
136 |
+
|
137 |
+
# Resolve conflicts manually, then
|
138 |
+
git add .
|
139 |
+
git commit -m "Resolve conflicts"
|
140 |
+
```
|
141 |
+
|
142 |
+
#### Force Push Safety
|
143 |
+
```bash
|
144 |
+
# Check what you're about to overwrite
|
145 |
+
git log azure/main --oneline -5
|
146 |
+
|
147 |
+
# Then force push if safe
|
148 |
+
./sync_repos_enhanced.sh "Your message" --force-azure
|
149 |
+
```
|
150 |
+
|
151 |
+
### Emergency Recovery
|
152 |
+
If something goes wrong:
|
153 |
+
1. **Don't panic**: Git keeps history
|
154 |
+
2. **Check both repositories**: See which has the latest changes
|
155 |
+
3. **Reset if needed**: `git reset --hard <commit-hash>`
|
156 |
+
4. **Re-apply changes**: If you lost work, check git reflog
|
157 |
+
|
158 |
+
## Scripts Available
|
159 |
+
|
160 |
+
- `sync_repos.sh`: Basic sync script (original)
|
161 |
+
- `sync_repos_enhanced.sh`: Enhanced script for collaborative work (recommended)
|
162 |
+
|
163 |
+
## Team Guidelines
|
164 |
+
|
165 |
+
1. **Primary Developer (You)**: Use enhanced sync script, coordinate with team
|
166 |
+
2. **Colleagues**: Work on Azure DevOps, communicate changes
|
167 |
+
3. **Everyone**: Use meaningful commit messages, test before pushing
|
168 |
+
4. **Emergency**: Contact primary developer before force pushing
|
169 |
+
|
170 |
+
This setup allows flexible collaboration while maintaining code integrity across both repositories.
|
sync_repos_enhanced.sh
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Enhanced sync script for collaborative work with both Hugging Face and Azure DevOps
|
4 |
+
# Usage: ./sync_repos_enhanced.sh [commit_message] [--force-azure]
|
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 |
+
BLUE='\033[0;34m'
|
13 |
+
NC='\033[0m' # No Color
|
14 |
+
|
15 |
+
# Parse arguments
|
16 |
+
COMMIT_MSG=${1:-"Auto-sync: $(date '+%Y-%m-%d %H:%M:%S')"}
|
17 |
+
FORCE_AZURE=false
|
18 |
+
|
19 |
+
if [[ "$2" == "--force-azure" ]]; then
|
20 |
+
FORCE_AZURE=true
|
21 |
+
fi
|
22 |
+
|
23 |
+
echo -e "${GREEN}π Starting enhanced repository sync...${NC}"
|
24 |
+
echo -e "${BLUE}π Commit message: ${COMMIT_MSG}${NC}"
|
25 |
+
echo -e "${BLUE}π§ Force Azure push: ${FORCE_AZURE}${NC}"
|
26 |
+
|
27 |
+
# Check if we're in a git repository
|
28 |
+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
29 |
+
echo -e "${RED}β Error: Not in a git repository${NC}"
|
30 |
+
exit 1
|
31 |
+
fi
|
32 |
+
|
33 |
+
# Function to check for conflicts
|
34 |
+
check_conflicts() {
|
35 |
+
if git ls-files -u | grep -q .; then
|
36 |
+
echo -e "${RED}β Merge conflicts detected! Please resolve them manually.${NC}"
|
37 |
+
echo -e "${YELLOW} Run: git status to see conflicted files${NC}"
|
38 |
+
echo -e "${YELLOW} After resolving: git add . && git commit${NC}"
|
39 |
+
exit 1
|
40 |
+
fi
|
41 |
+
}
|
42 |
+
|
43 |
+
# Function to fetch and merge from remote
|
44 |
+
fetch_and_merge() {
|
45 |
+
local remote_name=$1
|
46 |
+
local branch_name=${2:-main}
|
47 |
+
|
48 |
+
echo -e "${GREEN}π₯ Fetching from ${remote_name}...${NC}"
|
49 |
+
git fetch $remote_name
|
50 |
+
|
51 |
+
# Check if there are new commits on the remote
|
52 |
+
local local_commit=$(git rev-parse HEAD)
|
53 |
+
local remote_commit=$(git rev-parse $remote_name/$branch_name)
|
54 |
+
|
55 |
+
if [ "$local_commit" != "$remote_commit" ]; then
|
56 |
+
echo -e "${YELLOW}β οΈ New commits detected on ${remote_name}. Attempting merge...${NC}"
|
57 |
+
|
58 |
+
# Try to merge
|
59 |
+
if git merge $remote_name/$branch_name --no-edit; then
|
60 |
+
echo -e "${GREEN}β
Successfully merged changes from ${remote_name}${NC}"
|
61 |
+
else
|
62 |
+
echo -e "${RED}β Merge failed. Please resolve conflicts manually.${NC}"
|
63 |
+
echo -e "${YELLOW} Run: git status to see conflicted files${NC}"
|
64 |
+
echo -e "${YELLOW} After resolving: git add . && git commit${NC}"
|
65 |
+
exit 1
|
66 |
+
fi
|
67 |
+
else
|
68 |
+
echo -e "${GREEN}β
${remote_name} is up to date${NC}"
|
69 |
+
fi
|
70 |
+
}
|
71 |
+
|
72 |
+
# Check for uncommitted changes
|
73 |
+
if ! git diff-index --quiet HEAD --; then
|
74 |
+
echo -e "${YELLOW}β οΈ You have uncommitted changes. Please commit them first.${NC}"
|
75 |
+
echo -e "${YELLOW} Run: git add . && git commit -m \"your message\"${NC}"
|
76 |
+
exit 1
|
77 |
+
fi
|
78 |
+
|
79 |
+
# Fetch and merge from both remotes before pushing
|
80 |
+
echo -e "${GREEN}π Syncing with remote repositories...${NC}"
|
81 |
+
fetch_and_merge "origin" "main"
|
82 |
+
fetch_and_merge "azure" "main"
|
83 |
+
|
84 |
+
# Check for conflicts after merges
|
85 |
+
check_conflicts
|
86 |
+
|
87 |
+
# Add all changes and commit if there are any
|
88 |
+
if ! git diff-index --quiet HEAD --; then
|
89 |
+
echo -e "${GREEN}π¦ Adding and committing changes...${NC}"
|
90 |
+
git add .
|
91 |
+
git commit -m "$COMMIT_MSG"
|
92 |
+
fi
|
93 |
+
|
94 |
+
# Push to Hugging Face (origin)
|
95 |
+
echo -e "${GREEN}π Pushing to Hugging Face (origin)...${NC}"
|
96 |
+
if git push origin main; then
|
97 |
+
echo -e "${GREEN}β
Successfully pushed to Hugging Face${NC}"
|
98 |
+
else
|
99 |
+
echo -e "${RED}β Failed to push to Hugging Face${NC}"
|
100 |
+
exit 1
|
101 |
+
fi
|
102 |
+
|
103 |
+
# Push to Azure DevOps (azure)
|
104 |
+
echo -e "${GREEN}π Pushing to Azure DevOps (azure)...${NC}"
|
105 |
+
if [ "$FORCE_AZURE" = true ]; then
|
106 |
+
echo -e "${YELLOW}β οΈ Force pushing to Azure DevOps...${NC}"
|
107 |
+
if git push azure main --force; then
|
108 |
+
echo -e "${GREEN}β
Successfully force pushed to Azure DevOps${NC}"
|
109 |
+
else
|
110 |
+
echo -e "${RED}β Failed to force push to Azure DevOps${NC}"
|
111 |
+
exit 1
|
112 |
+
fi
|
113 |
+
else
|
114 |
+
if git push azure main; then
|
115 |
+
echo -e "${GREEN}β
Successfully pushed to Azure DevOps${NC}"
|
116 |
+
else
|
117 |
+
echo -e "${YELLOW}β οΈ Regular push failed. You can:${NC}"
|
118 |
+
echo -e "${YELLOW} 1. Run: ./sync_repos_enhanced.sh \"$COMMIT_MSG\" --force-azure${NC}"
|
119 |
+
echo -e "${YELLOW} 2. Or manually resolve conflicts and push${NC}"
|
120 |
+
echo -e "${YELLOW} 3. Or fetch and merge from Azure first: git fetch azure && git merge azure/main${NC}"
|
121 |
+
exit 1
|
122 |
+
fi
|
123 |
+
fi
|
124 |
+
|
125 |
+
echo -e "${GREEN}π Enhanced repository sync completed successfully!${NC}"
|
126 |
+
echo -e "${GREEN}π Remotes configured:${NC}"
|
127 |
+
git remote -v
|
128 |
+
|
129 |
+
echo -e "${BLUE}π‘ Tips for collaborative work:${NC}"
|
130 |
+
echo -e "${BLUE} β’ Always run this script before starting new work${NC}"
|
131 |
+
echo -e "${BLUE} β’ Use --force-azure only when you're sure you want to overwrite Azure changes${NC}"
|
132 |
+
echo -e "${BLUE} β’ Communicate with your team about which repository to use as primary${NC}"
|