-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-script.sh
More file actions
executable file
·70 lines (58 loc) · 2.31 KB
/
sync-script.sh
File metadata and controls
executable file
·70 lines (58 loc) · 2.31 KB
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
65
66
67
68
69
70
#!/bin/bash
# Script to sync changes from upstream repository while preserving local customizations
# Exit on error
set -e
echo "Starting sync process with upstream repository..."
# Make sure we're on the main branch
git checkout main
echo "✓ Checked out main branch"
# Add the upstream remote if it doesn't exist
if ! git remote | grep -q "upstream"; then
# Using HTTPS URL for the public upstream repository
git remote add upstream https://github.com/case-framework/case-admin.git
echo "✓ Added upstream remote (public repository)"
else
echo "✓ Upstream remote already exists"
fi
# Verify origin remote is using appropriate authentication method for private repo
ORIGIN_URL=$(git remote get-url origin)
if [[ "$ORIGIN_URL" != ssh* ]] && [[ "$ORIGIN_URL" != https://.*@github.com* ]]; then
echo "⚠️ Warning: Your origin remote may not be configured with authentication."
echo " For a private repository, consider using SSH or HTTPS with token:"
echo " - SSH: git remote set-url origin git@github.com:my-org/case-admin.git"
echo " - HTTPS: git remote set-url origin https://username:token@github.com/my-org/case-admin.git"
fi
# Fetch the latest changes from upstream
git fetch upstream
echo "✓ Fetched latest changes from upstream"
# Make sure upstream branch exists locally
if ! git show-ref --verify --quiet refs/heads/upstream; then
# Create upstream branch tracking the upstream repo's main branch
git checkout -b upstream upstream/main
echo "✓ Created local upstream branch"
else
# Update the upstream branch with the latest changes
git checkout upstream
git pull upstream main
echo "✓ Updated local upstream branch"
fi
# Return to main branch
git checkout main
echo "✓ Switched back to main branch"
# Merge changes from upstream branch
echo "Merging changes from upstream..."
git merge upstream --no-commit
# Check for conflicts
if [ $? -ne 0 ]; then
echo "⚠️ Merge conflicts detected."
echo "Please resolve conflicts manually, then commit the changes."
echo "Files with customizations (like favicon, app name) may need special attention."
exit 1
fi
echo "Ready to commit merged changes."
echo "Review the changes before committing:"
echo " git diff --staged"
echo ""
echo "To commit the changes:"
echo " git commit -m 'Merge upstream changes'"
echo " git push origin main"