ensure rev sync
This commit is contained in:
+34
-2
@@ -5,10 +5,42 @@ $Root = Split-Path -Parent $ScriptDir
|
||||
$SingBox = Join-Path $Root 'works/sing-box'
|
||||
$PatchDir = Join-Path $Root 'works/patch'
|
||||
$Output = Join-Path $Root 'works/core'
|
||||
$RevFile = Join-Path $Root 'works/rev'
|
||||
|
||||
# defaults
|
||||
$RepoUrl = 'git@git.inker.bot:arknights/sing-box.git'
|
||||
$UpstreamBranch = 'main'
|
||||
|
||||
$ConfigFile = Join-Path $Root 'works/config'
|
||||
if (Test-Path $ConfigFile) {
|
||||
Get-Content $ConfigFile | ForEach-Object {
|
||||
if ($_ -match '^([^#=]+)=(.*)$') {
|
||||
$key = $Matches[1].Trim()
|
||||
$val = $Matches[2].Trim()
|
||||
if ($key -eq 'REPO_URL') { $RepoUrl = $val }
|
||||
elseif ($key -eq 'UPSTREAM_BRANCH') { $UpstreamBranch = $val }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Clone if not present
|
||||
if (-not (Test-Path (Join-Path $SingBox '.git'))) {
|
||||
Write-Error 'works/sing-box not found. Run update first.'
|
||||
exit 1
|
||||
Write-Host 'Cloning sing-box...'
|
||||
if ($UpstreamBranch) {
|
||||
git clone -b $UpstreamBranch $RepoUrl $SingBox
|
||||
} else {
|
||||
git clone $RepoUrl $SingBox
|
||||
}
|
||||
}
|
||||
|
||||
# Checkout stored rev
|
||||
if (Test-Path $RevFile) {
|
||||
$Rev = (Get-Content $RevFile -Raw).Trim()
|
||||
Write-Host "Checking out stored rev: $Rev"
|
||||
git -C $SingBox fetch --all
|
||||
git -C $SingBox checkout $Rev
|
||||
} else {
|
||||
Write-Host 'Warning: works/rev not found, using current HEAD.' -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host 'Initializing works/core/...'
|
||||
|
||||
Reference in New Issue
Block a user