This commit is contained in:
2026-01-11 10:59:50 -08:00
parent 5f8f49c530
commit 234f7aca5c
9 changed files with 112 additions and 53 deletions

View File

@@ -1094,6 +1094,26 @@ def main() -> int:
ps1_text = r"""Param([Parameter(ValueFromRemainingArguments=$true)] $args)
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repo = (Resolve-Path (Join-Path $scriptDir "..")).Path
# Automatically check for updates if this is a git repository
if (Test-Path (Join-Path $repo ".git")) {
try {
if (-not $env:MM_NO_UPDATE) {
$conf = Join-Path $repo "config.conf"
$skip = $false
if (Test-Path $conf) {
if ((Get-Content $conf | Select-String "auto_update\s*=\s*(false|no|off|0)") -ne $null) {
$skip = $true
}
}
if (-not $skip) {
Write-Host "Checking for updates..." -ForegroundColor Gray
git -C "$repo" pull --ff-only --quiet
}
}
} catch {}
}
$venv = Join-Path $repo '.venv'
$py = Join-Path $venv 'Scripts\python.exe'
if (Test-Path $py) {
@@ -1139,6 +1159,22 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
"@echo off\n"
"setlocal enabledelayedexpansion\n"
f'set "REPO={repo_bat_str}"\n'
"\n"
"# Automatically check for updates if this is a git repository\n"
"if not defined MM_NO_UPDATE (\n"
" if exist \"!REPO!\\.git\" (\n"
" set \"AUTO_UPDATE=true\"\n"
" if exist \"!REPO!\\config.conf\" (\n"
" findstr /i /r \"auto_update.*=.*false auto_update.*=.*no auto_update.*=.*off auto_update.*=.*0\" \"!REPO!\\config.conf\" >nul 2>&1\n"
" if !errorlevel! == 0 set \"AUTO_UPDATE=false\"\n"
" )\n"
" if \"!AUTO_UPDATE!\" == \"true\" (\n"
" echo Checking for updates...\n"
" git -C \"!REPO!\" pull --ff-only --quiet\n"
" )\n"
" )\n"
")\n"
"\n"
"set \"VENV=!REPO!\\.venv\"\n"
"set \"PY=!VENV!\\Scripts\\python.exe\"\n"
"set \"ENTRY=!REPO!\\scripts\\cli_entry.py\"\n"
@@ -1299,6 +1335,21 @@ if (Test-Path (Join-Path $repo 'CLI.py')) {
" done\n"
' echo "MM_DEBUG: end diagnostics" >&2\n'
"fi\n"
"\n"
"# Automatically check for updates if this is a git repository\n"
'if [ -z "${MM_NO_UPDATE:-}" ] && [ -d "$REPO/.git" ] && command -v git >/dev/null 2>&1; then\n'
' AUTO_UPDATE="true"\n'
' if [ -f "$REPO/config.conf" ]; then\n'
' if grep -qiE \'auto_update\s*=\s*(false|no|off|0)\' "$REPO/config.conf"; then\n'
' AUTO_UPDATE="false"\n'
' fi\n'
' fi\n'
' if [ "$AUTO_UPDATE" = "true" ]; then\n'
' echo "Checking for updates..."\n'
' git -C "$REPO" pull --ff-only --quiet || true\n'
' fi\n'
"fi\n"
"\n"
"# Use -m scripts.cli_entry directly instead of pip-generated wrapper to avoid entry point issues\n"
"# Prefer venv's python3, then venv's python\n"
'if [ -x "$VENV/bin/python3" ]; then\n'