ensure rev sync
This commit is contained in:
@@ -6,10 +6,35 @@ ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
SING_BOX="$ROOT/works/sing-box"
|
||||
PATCH_DIR="$ROOT/works/patch"
|
||||
OUTPUT="$ROOT/works/core"
|
||||
REV_FILE="$ROOT/works/rev"
|
||||
|
||||
# defaults
|
||||
REPO_URL="git@git.inker.bot:arknights/sing-box.git"
|
||||
UPSTREAM_BRANCH="main"
|
||||
|
||||
CONFIG="$ROOT/works/config"
|
||||
if [ -f "$CONFIG" ]; then
|
||||
. "$CONFIG"
|
||||
fi
|
||||
|
||||
# Clone if not present
|
||||
if [ ! -d "$SING_BOX/.git" ]; then
|
||||
echo "Error: works/sing-box not found. Run update first." >&2
|
||||
exit 1
|
||||
echo "Cloning sing-box..."
|
||||
if [ -n "$UPSTREAM_BRANCH" ]; then
|
||||
git clone -b "$UPSTREAM_BRANCH" "$REPO_URL" "$SING_BOX"
|
||||
else
|
||||
git clone "$REPO_URL" "$SING_BOX"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checkout stored rev
|
||||
if [ -f "$REV_FILE" ]; then
|
||||
REV="$(cat "$REV_FILE" | tr -d '[:space:]')"
|
||||
echo "Checking out stored rev: $REV"
|
||||
git -C "$SING_BOX" fetch --all
|
||||
git -C "$SING_BOX" checkout "$REV"
|
||||
else
|
||||
echo "Warning: works/rev not found, using current HEAD." >&2
|
||||
fi
|
||||
|
||||
echo "Initializing works/core/..."
|
||||
|
||||
+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/...'
|
||||
|
||||
+6
-1
@@ -4,6 +4,7 @@ set -e
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
SING_BOX="$ROOT/works/sing-box"
|
||||
REV_FILE="$ROOT/works/rev"
|
||||
|
||||
# defaults
|
||||
REPO_URL="git@git.inker.bot:arknights/sing-box.git"
|
||||
@@ -30,4 +31,8 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done. Version: $(git -C "$SING_BOX" describe --tags --always 2>/dev/null || git -C "$SING_BOX" rev-parse --short HEAD)"
|
||||
REV="$(git -C "$SING_BOX" rev-parse HEAD)"
|
||||
echo "$REV" > "$REV_FILE"
|
||||
|
||||
echo "Done. Version: $(git -C "$SING_BOX" describe --tags --always 2>/dev/null || echo "$REV")"
|
||||
echo "Stored rev: $REV"
|
||||
|
||||
+6
-1
@@ -3,6 +3,7 @@ $ErrorActionPreference = 'Stop'
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$Root = Split-Path -Parent $ScriptDir
|
||||
$SingBox = Join-Path $Root 'works/sing-box'
|
||||
$RevFile = Join-Path $Root 'works/rev'
|
||||
|
||||
# defaults
|
||||
$RepoUrl = 'git@git.inker.bot:arknights/sing-box.git'
|
||||
@@ -34,6 +35,10 @@ if (Test-Path (Join-Path $SingBox '.git')) {
|
||||
}
|
||||
}
|
||||
|
||||
$Rev = git -C $SingBox rev-parse HEAD
|
||||
Set-Content -Path $RevFile -Value $Rev -NoNewline
|
||||
|
||||
$version = git -C $SingBox describe --tags --always 2>$null
|
||||
if (-not $version) { $version = git -C $SingBox rev-parse --short HEAD }
|
||||
if (-not $version) { $version = $Rev.Substring(0, 7) }
|
||||
Write-Host "Done. Version: $version"
|
||||
Write-Host "Stored rev: $Rev"
|
||||
|
||||
Reference in New Issue
Block a user