Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-database
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-database
Commits
7ba546c8
Commit
7ba546c8
authored
May 08, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test sql merge
parent
a1821c5b
Pipeline
#36056
passed with stage
in 45 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
175 additions
and
0 deletions
+175
-0
.gitattributes
.gitattributes
+1
-0
scripts/sqlite-diff.sh
scripts/sqlite-diff.sh
+24
-0
scripts/sqlite-merge.sh
scripts/sqlite-merge.sh
+61
-0
setup.sh
setup.sh
+89
-0
No files found.
.gitattributes
0 → 100644
View file @
7ba546c8
*.cdb merge=sqlite-merge diff=sqlite-diff
scripts/sqlite-diff.sh
0 → 100644
View file @
7ba546c8
#!/bin/sh
# Input SQLite database path
DB
=
"
$1
"
# Locate sqlite3 binary
if
[
-n
"
$SQLITE3_BIN
"
]
;
then
SQLITE3
=
"
$SQLITE3_BIN
"
elif
command
-v
sqlite3
>
/dev/null 2>&1
;
then
SQLITE3
=
"sqlite3"
elif
command
-v
sqlite3.exe
>
/dev/null 2>&1
;
then
SQLITE3
=
"sqlite3.exe"
elif
[
-x
"./bin/sqlite3"
]
;
then
SQLITE3
=
"./bin/sqlite3"
elif
[
-x
"./bin/sqlite3.exe"
]
;
then
SQLITE3
=
"./bin/sqlite3.exe"
else
echo
"❌ Error: sqlite3 binary not found."
echo
"Please set the SQLITE3_BIN environment variable or install sqlite3."
exit
1
fi
# Run .dump and filter out noise
"
$SQLITE3
"
"
$DB
"
.dump |
grep
-v
'^--'
|
grep
-v
'^PRAGMA'
scripts/sqlite-merge.sh
0 → 100644
View file @
7ba546c8
#!/bin/sh
# Locate sqlite3 binary
if
[
-n
"
$SQLITE3_BIN
"
]
;
then
SQLITE3
=
"
$SQLITE3_BIN
"
elif
command
-v
sqlite3
>
/dev/null 2>&1
;
then
SQLITE3
=
"sqlite3"
elif
command
-v
sqlite3.exe
>
/dev/null 2>&1
;
then
SQLITE3
=
"sqlite3.exe"
elif
[
-x
"./bin/sqlite3"
]
;
then
SQLITE3
=
"./bin/sqlite3"
elif
[
-x
"./bin/sqlite3.exe"
]
;
then
SQLITE3
=
"./bin/sqlite3.exe"
else
echo
"❌ Error: sqlite3 binary not found."
echo
"Please set the SQLITE3_BIN environment variable or install sqlite3."
exit
1
fi
BASE
=
"
$1
"
OURS
=
"
$2
"
THEIRS
=
"
$3
"
RESULT
=
"
$2
"
FILE_PATH
=
"
$5
"
CONFLICT_FILE
=
"
$FILE_PATH
.sql"
TMPDIR
=
$(
mktemp
-d
)
||
exit
1
# 手动清理函数
cleanup
()
{
rm
-rf
"
$TMPDIR
"
}
# 不用 trap,因为 sh 没有 EXIT trap,靠手动调用
"
$SQLITE3
"
"
$BASE
"
.dump
>
"
$TMPDIR
/base.sql"
||
{
cleanup
;
exit
1
;
}
"
$SQLITE3
"
"
$OURS
"
.dump
>
"
$TMPDIR
/ours.sql"
||
{
cleanup
;
exit
1
;
}
"
$SQLITE3
"
"
$THEIRS
"
.dump
>
"
$TMPDIR
/theirs.sql"
||
{
cleanup
;
exit
1
;
}
git merge-file
-p
"
$TMPDIR
/ours.sql"
"
$TMPDIR
/base.sql"
"
$TMPDIR
/theirs.sql"
>
"
$TMPDIR
/merged.sql"
MERGE_EXIT_CODE
=
$?
if
grep
'^<<<<<<<'
"
$TMPDIR
/merged.sql"
>
/dev/null
;
then
echo
"❌ Merge conflict detected. Please resolve:"
echo
" -->
$CONFLICT_FILE
"
cp
"
$TMPDIR
/merged.sql"
"
$CONFLICT_FILE
"
cleanup
exit
1
# 保留冲突文件,人工处理,故不 cleanup
fi
echo
''
>
"
$RESULT
"
"
$SQLITE3
"
"
$RESULT
"
<
"
$TMPDIR
/merged.sql"
||
{
echo
"❌ Failed to import merged SQL"
echo
" -->
$CONFLICT_FILE
"
cp
"
$TMPDIR
/merged.sql"
"
$CONFLICT_FILE
"
cleanup
exit
1
}
echo
"✅ Merged successfully to
$FILE_PATH
"
cleanup
exit
0
setup.sh
0 → 100644
View file @
7ba546c8
#!/bin/sh
set
-e
# Attempt to find sqlite3, including environment override and local bin/
find_sqlite3
()
{
if
[
-n
"
$SQLITE3_BIN
"
]
&&
[
-x
"
$SQLITE3_BIN
"
]
;
then
echo
"
$SQLITE3_BIN
"
return
0
fi
if
command
-v
sqlite3
>
/dev/null 2>&1
;
then
echo
"sqlite3"
return
0
fi
if
command
-v
sqlite3.exe
>
/dev/null 2>&1
;
then
echo
"sqlite3.exe"
return
0
fi
if
[
-x
"./bin/sqlite3"
]
;
then
echo
"./bin/sqlite3"
return
0
fi
if
[
-x
"./bin/sqlite3.exe"
]
;
then
echo
"./bin/sqlite3.exe"
return
0
fi
return
1
}
install_sqlite3_windows
()
{
echo
"🔍 sqlite3 not found — downloading for Windows..."
mkdir
-p
bin
ZIP_URL
=
"https://sqlite.org/2025/sqlite-tools-win-x64-3490200.zip"
ZIP_FILE
=
"bin/sqlite3.zip"
# Only download if the zip file or binaries aren't already there
if
!
[
-f
"
$ZIP_FILE
"
]
||
!
find bin
-iname
"sqlite3.exe"
|
grep
-q
.
;
then
echo
"⬇️ Downloading SQLite tools..."
curl
-sL
-o
"
$ZIP_FILE
"
"
$ZIP_URL
"
||
{
echo
"❌ Failed to download SQLite zip from
$ZIP_URL
"
exit
1
}
echo
"📦 Extracting..."
unzip
-o
"
$ZIP_FILE
"
-d
bin
||
{
echo
"❌ Failed to unzip SQLite tools"
exit
1
}
else
echo
"✅ sqlite3 already exists in bin/, skipping download"
fi
}
# --- Main logic ---
SQLITE3_PATH
=
$(
find_sqlite3
)
if
[
-z
"
$SQLITE3_PATH
"
]
;
then
UNAME
=
$(
uname
|
tr
'[:upper:]'
'[:lower:]'
)
if
echo
"
$UNAME
"
|
grep
-qi
"mingw
\\
|msys
\\
|cygwin"
;
then
install_sqlite3_windows
SQLITE3_PATH
=
$(
find_sqlite3
)
else
echo
"❌ sqlite3 not found in PATH or ./bin/"
echo
"Please install sqlite3 manually (e.g., via apt, brew, or your package manager)."
exit
1
fi
fi
echo
"✅ Using sqlite3:
$SQLITE3_PATH
"
export
SQLITE3_BIN
=
"
$SQLITE3_PATH
"
# --- Git configuration ---
git config merge.sqlite-merge.name
"SQLite dump merge"
git config merge.sqlite-merge.driver
"scripts/sqlite-merge.sh %O %A %B %L %P"
git config diff.sqlite-diff.textconv
"scripts/sqlite-diff.sh"
git config diff.sqlite-diff.prompt
false
echo
"✅ Git merge & diff drivers configured successfully."
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment