Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
forked from anomalyco/opencode
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-upstream.sh
More file actions
Latest commit
executable file
·84 lines (71 loc) · 2.29 KB
/
Copy pathsync-upstream.sh
File metadata and controls
executable file
·84 lines (71 loc) · 2.29 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
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# Sync SkyCode OpenCode Fork with Upstream
# This script syncs the skycode-opencode fork with the upstream OpenCode repository
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"&& pwd)"
cd"$SCRIPT_DIR"
echo"🔄 Syncing skycode-opencode fork with upstream..."
# Check if upstream remote exists
if! git remote | grep -q "^upstream$";then
echo"📡 Adding upstream remote..."
git remote add upstream https://github.com/opencode-ai/opencode.git || {
echo"⚠️ Upstream remote might already exist with different URL"
echo" Current remotes:"
git remote -v
read -p "Continue anyway? (y/n) " -n 1 -r
echo
if [[ !$REPLY=~ ^[Yy]$ ]];then
exit 1
fi
}
fi
# Fetch upstream
echo"📥 Fetching upstream changes..."
git fetch upstream
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
echo"📍 Current branch: $CURRENT_BRANCH"
# Check if there are local uncommitted changes
if! git diff-index --quiet HEAD --;then
echo"⚠️ Warning: You have uncommitted changes!"
echo" Stashing changes..."
git stash push -m "Auto-stash before upstream sync $(date +%Y-%m-%d)"
STASHED=true
else
STASHED=false
fi
# Merge upstream changes
echo"🔀 Merging upstream/main into $CURRENT_BRANCH..."
git merge upstream/main --no-edit || {
echo"❌ Merge conflict detected!"
echo" Resolve conflicts manually, then run:"
echo" git add ."
echo" git commit"
if [ "$STASHED"=true ];then
echo" Restoring stashed changes..."
git stash pop
fi
exit 1
}
# If we stashed changes, restore them
if [ "$STASHED"=true ];then
echo"♻️ Restoring stashed changes..."
git stash pop || {
echo"⚠️ Could not automatically restore stashed changes"
echo" Run 'git stash list' to see stashed changes"
}
fi
# Show summary
echo""
echo"✅ Sync complete!"
echo""
echo"📊 Summary:"
echo" Branch: $CURRENT_BRANCH"
echo" Upstream: $(git rev-parse upstream/main --short 2>/dev/null ||echo'N/A')"
echo" Local: $(git rev-parse HEAD --short)"
echo""
echo"💡 Next steps:"
echo" 1. Review changes: git log upstream/main..HEAD"
echo" 2. Test your changes"
echo" 3. Push to origin: git push"
echo""