Skip to content

Commit 0b1ccb1

Browse files
authored
Merge pull request #9 from unnc-aim/develop
Merge develop into main
2 parents 3b775aa + 48981b3 commit 0b1ccb1

File tree

3 files changed

+160
-2
lines changed

3 files changed

+160
-2
lines changed

.github/workflows/sync-develop.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Sync Develop Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch: # 允许手动触发
8+
9+
jobs:
10+
sync-develop:
11+
name: Sync develop branch with main
12+
runs-on: ubuntu-latest
13+
if: github.ref == 'refs/heads/main'
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
# 获取完整的 git 历史,以便进行分支操作
20+
fetch-depth: 0
21+
# 使用 GitHub Token 进行身份验证
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Configure Git
25+
run: |
26+
git config --global user.name "github-actions[bot]"
27+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
28+
29+
- name: Fetch all branches
30+
run: |
31+
git fetch origin main
32+
git fetch origin develop
33+
34+
- name: Check if develop branch exists
35+
id: check-develop
36+
run: |
37+
if git show-ref --verify --quiet refs/remotes/origin/develop; then
38+
echo "exists=true" >> $GITHUB_OUTPUT
39+
echo "✅ develop branch exists"
40+
else
41+
echo "exists=false" >> $GITHUB_OUTPUT
42+
echo "❌ develop branch does not exist"
43+
fi
44+
45+
- name: Create develop branch if it doesn't exist
46+
if: steps.check-develop.outputs.exists == 'false'
47+
run: |
48+
echo "🔧 Creating develop branch from main..."
49+
git checkout -b develop
50+
if git push origin develop; then
51+
echo "✅ develop branch created and pushed"
52+
else
53+
echo "❌ Failed to push develop branch - likely a permissions issue"
54+
echo "permission_error=true" >> $GITHUB_ENV
55+
exit 1
56+
fi
57+
58+
- name: Sync develop with main
59+
if: steps.check-develop.outputs.exists == 'true'
60+
run: |
61+
echo "🔄 Syncing develop branch with main..."
62+
63+
# 切换到 develop 分支
64+
git checkout develop
65+
66+
# 获取当前分支的最新提交 hash
67+
DEVELOP_BEFORE=$(git rev-parse HEAD)
68+
echo "📋 develop branch before sync: $DEVELOP_BEFORE"
69+
70+
# 获取 main 分支的最新提交 hash
71+
MAIN_COMMIT=$(git rev-parse origin/main)
72+
echo "📋 main branch commit: $MAIN_COMMIT"
73+
74+
# 检查是否需要同步
75+
if [ "$DEVELOP_BEFORE" = "$MAIN_COMMIT" ]; then
76+
echo "✅ develop branch is already up to date with main"
77+
exit 0
78+
fi
79+
80+
# 尝试快进合并 main 到 develop
81+
echo "🚀 Attempting fast-forward merge..."
82+
if git merge --ff-only origin/main; then
83+
echo "✅ Fast-forward merge successful"
84+
85+
# 推送更新到远程 develop 分支
86+
if git push origin develop; then
87+
echo "✅ Push to develop successful"
88+
else
89+
echo "❌ Failed to push to develop branch - likely a permissions issue"
90+
echo "permission_error=true" >> $GITHUB_ENV
91+
exit 1
92+
fi
93+
94+
DEVELOP_AFTER=$(git rev-parse HEAD)
95+
echo "📋 develop branch after sync: $DEVELOP_AFTER"
96+
echo "🎉 develop branch successfully synced with main"
97+
98+
else
99+
echo "⚠️ Fast-forward merge failed, there might be conflicts or diverged commits"
100+
echo "📋 This usually happens when develop has commits that are not in main"
101+
echo "🔍 Checking for diverged commits..."
102+
103+
# 检查 develop 是否有 main 没有的提交
104+
DIVERGED_COMMITS=$(git rev-list --count origin/main..develop)
105+
echo "📊 Number of commits in develop not in main: $DIVERGED_COMMITS"
106+
107+
if [ "$DIVERGED_COMMITS" -gt 0 ]; then
108+
echo "⚠️ develop branch has $DIVERGED_COMMITS commits that are not in main"
109+
echo "🔧 This requires manual intervention or a different sync strategy"
110+
echo "📋 Diverged commits:"
111+
git log --oneline origin/main..develop
112+
113+
echo "💡 Consider creating a pull request to merge these changes to main first"
114+
exit 1
115+
else
116+
echo "❌ Unexpected merge failure"
117+
exit 1
118+
fi
119+
fi
120+
121+
- name: Create summary
122+
if: always()
123+
run: |
124+
echo "## 🔄 Develop Branch Sync Summary" >> $GITHUB_STEP_SUMMARY
125+
echo "" >> $GITHUB_STEP_SUMMARY
126+
echo "- **Trigger**: Push to main branch" >> $GITHUB_STEP_SUMMARY
127+
echo "- **Main commit**: \`$(git rev-parse origin/main)\`" >> $GITHUB_STEP_SUMMARY
128+
129+
if [ "${{ steps.check-develop.outputs.exists }}" = "true" ]; then
130+
echo "- **Develop branch**: Existed and processed" >> $GITHUB_STEP_SUMMARY
131+
else
132+
echo "- **Develop branch**: Created from main" >> $GITHUB_STEP_SUMMARY
133+
fi
134+
135+
echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY
136+
echo "" >> $GITHUB_STEP_SUMMARY
137+
138+
if [ "${{ job.status }}" = "success" ]; then
139+
echo "✅ **Result**: develop branch is now in sync with main" >> $GITHUB_STEP_SUMMARY
140+
else
141+
echo "❌ **Result**: Sync failed - manual intervention may be required" >> $GITHUB_STEP_SUMMARY
142+
143+
# Check if it's a permission error
144+
if [ "${permission_error:-false}" = "true" ]; then
145+
echo "" >> $GITHUB_STEP_SUMMARY
146+
echo "## 🔧 Permission Error Fix" >> $GITHUB_STEP_SUMMARY
147+
echo "" >> $GITHUB_STEP_SUMMARY
148+
echo "The sync failed due to insufficient permissions. To fix this:" >> $GITHUB_STEP_SUMMARY
149+
echo "" >> $GITHUB_STEP_SUMMARY
150+
echo "1. Go to your repository **Settings** → **Actions** → **General**" >> $GITHUB_STEP_SUMMARY
151+
echo "2. Under **Workflow permissions**, select **Read and write permissions**" >> $GITHUB_STEP_SUMMARY
152+
echo "3. Check **Allow GitHub Actions to create and approve pull requests** (optional)" >> $GITHUB_STEP_SUMMARY
153+
echo "4. Click **Save** and re-run this workflow" >> $GITHUB_STEP_SUMMARY
154+
echo "" >> $GITHUB_STEP_SUMMARY
155+
echo "**Direct link**: \`https://github.com/${{ github.repository }}/settings/actions\`" >> $GITHUB_STEP_SUMMARY
156+
fi
157+
fi

database/migration_001_dataset_configs.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- Migration 001: 创建数据集配置表
22
-- 用于支持不同格式的数据集(YOLO、DJI ROCO 等)
3-
3+
USE torch_markup
44
CREATE TABLE IF NOT EXISTS dataset_configs (
55
id INT AUTO_INCREMENT PRIMARY KEY,
66
dataset_id INT NOT NULL UNIQUE,

frontend/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vite build",
9-
"preview": "vite preview"
9+
"preview": "vite preview",
10+
"deploy": "vite build && cp -r ./dist/ ../sslly-nginx/static/torch-markup-frontend"
1011
},
1112
"dependencies": {
1213
"@element-plus/icons-vue": "^2.3.2",

0 commit comments

Comments
 (0)