use git for updating artemis
This commit is contained in:
parent
5cdb7055e5
commit
45b1b2aa19
|
@ -1,3 +1,4 @@
|
|||
work
|
||||
*.zip
|
||||
*.7z
|
||||
*.7z
|
||||
artemis-portable
|
|
@ -1,42 +1,18 @@
|
|||
$artemis_repo = "%%ARTEMIS_REPO%%"
|
||||
$artemis_branch = "%%ARTEMIS_BRANCH%%"
|
||||
|
||||
$old = Join-Path $(Get-Location) "artemis"
|
||||
$tmpdir = Join-Path $env:TEMP $(New-Guid)
|
||||
New-Item -ItemType Directory -Path $tmpdir
|
||||
$artemis_location = Join-Path $(Get-Location) "artemis"
|
||||
|
||||
cd $tmpdir
|
||||
python/python.exe scripts/update-artemis.py "$artemis_repo" "$artemis_branch"
|
||||
|
||||
Write-Output "[INFO] Downloading ARTEMiS..."
|
||||
Invoke-WebRequest "https://gitea.tendokyu.moe/$artemis_repo/archive/$artemis_branch.zip" -OutFile "artemis-$artemis_branch.zip"
|
||||
Expand-Archive "artemis-$artemis_branch.zip"
|
||||
Move-Item "artemis-$artemis_branch/artemis" artemis
|
||||
Remove-Item -Recurse "artemis-$artemis_branch"
|
||||
Remove-Item "artemis-$artemis_branch.zip"
|
||||
|
||||
Write-Output "[INFO] Copying files..."
|
||||
(Get-ChildItem "$tmpdir/artemis/*").FullName | Copy-Item -Destination "$old" -Recurse -Force
|
||||
|
||||
Set-Location "$old"
|
||||
Set-Location "$artemis_location"
|
||||
Write-Output "[INFO] Updating dependencies..."
|
||||
../python/python.exe -m pip install --no-warn-script-location -r requirements.txt
|
||||
|
||||
Write-Output "[INFO] Migrating databases..."
|
||||
$mariadb = Start-Process -NoNewWindow -PassThru -WorkingDirectory ..\mariadb ..\mariadb\bin\mysqld.exe --console
|
||||
../python/python.exe dbutils.py upgrade
|
||||
Get-ChildItem -Name .\core\data\schema\versions | ForEach-Object {
|
||||
$schema = ($_ -split "_")[0]
|
||||
if ($schema -eq "CORE") {
|
||||
return
|
||||
} else {
|
||||
return $schema
|
||||
}
|
||||
} | Get-Unique | ForEach-Object {
|
||||
../python/python.exe dbutils.py --game "$_" upgrade
|
||||
}
|
||||
../python/python.exe dbutils.py autoupgrade
|
||||
Stop-Process $mariadb.Id
|
||||
|
||||
Remove-Item -Recurse "$tmpdir"
|
||||
|
||||
Write-Output "ARTEMiS update finished."
|
||||
cmd /k pause
|
|
@ -0,0 +1,37 @@
|
|||
import sys
|
||||
import pygit2
|
||||
|
||||
ARTEMIS_REPO = sys.argv[1]
|
||||
ARTEMIS_BRANCH = sys.argv[2]
|
||||
|
||||
repo = pygit2.Repository("artemis/.git")
|
||||
|
||||
repo.config.set_multivar("remote.origin.url", "", ARTEMIS_REPO)
|
||||
|
||||
branch = repo.lookup_branch(ARTEMIS_BRANCH)
|
||||
ref = repo.lookup_reference(branch.name)
|
||||
repo.checkout(ref)
|
||||
|
||||
for remote in repo.remotes:
|
||||
if remote.name != "origin":
|
||||
continue
|
||||
|
||||
remote.fetch()
|
||||
|
||||
remote_master_id = repo.lookup_reference(f"refs/remotes/origin/{ARTEMIS_BRANCH}").target
|
||||
merge_result, _ = repo.merge_analysis(remote_master_id)
|
||||
|
||||
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
|
||||
print("[INFO] ARTEMiS is up to date.")
|
||||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
|
||||
repo.checkout_tree(repo.get(remote_master_id))
|
||||
|
||||
master_ref = repo.lookup_reference(f"refs/heads/{ARTEMIS_BRANCH}")
|
||||
|
||||
master_ref.set_target(remote_master_id)
|
||||
repo.head.set_target(remote_master_id)
|
||||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
|
||||
print("[ERROR] You have local changes that leads to a conflict. good luck lmao.")
|
||||
exit(1)
|
||||
|
||||
|
|
@ -26,6 +26,8 @@ New-Item -ItemType Directory python/DLLs
|
|||
curl.exe -L https://bootstrap.pypa.io/get-pip.py | python/python.exe -
|
||||
Remove-Item "python-$python_version-embed-amd64.zip"
|
||||
|
||||
python/python.exe -m pip install wheel pygit2
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Setting up MariaDB
|
||||
# --------------------------------------------------------
|
||||
|
@ -90,9 +92,7 @@ Set-Location ..
|
|||
# Setting up ARTEMiS
|
||||
# ----------------------------------------------------
|
||||
Write-Output "[INFO] Downloading ARTEMiS..."
|
||||
curl.exe -L -o "artemis-$artemis_branch.zip" "https://gitea.tendokyu.moe/$artemis_repo/archive/$artemis_branch.zip"
|
||||
7z.exe x "artemis-$artemis_branch.zip"
|
||||
Remove-Item "artemis-$artemis_branch.zip"
|
||||
git.exe clone -b $artemis_branch "https://gitea.tendokyu.moe/$artemis_repo"
|
||||
|
||||
Set-Location artemis
|
||||
|
||||
|
|
Loading…
Reference in New Issue