Force web config updates by default with backups
Config Central CI Config Central passed all CI integrity checks.
Beffroi/config-central/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-10-19 13:46:15 +02:00
parent 348d8d322c
commit f8b4aa0937
5 changed files with 16 additions and 10 deletions

View File

@ -32,9 +32,9 @@ This downloads the latest configs and updater code from your saved repository
branch and applies them to your saved machine profile. No menu, manual Git pull,
or software installation. Temporary downloads are removed afterward.
Unchanged configs are skipped and replacements are backed up. Local edits are
reported as conflicts instead of being silently lost; see
[replacing local edits](docs/advanced_commands.md#web-config-updater).
Unchanged configs are skipped. Local settings are backed up and replaced with
the repository versions by default. To preserve local edits instead, see
[advanced update options](docs/advanced_commands.md#web-config-updater).
Windows may request administrator approval for settings such as the hosts file.
## Collect settings from a computer

View File

@ -126,3 +126,4 @@ open until it is run on disposable machines with the required account setups.
- [x] Rename the bundled default machine to beffroi-laptop and document switching existing setups.
- [x] Use PowerShell 7-compatible ACL application for elevation requests; add Windows-only permission regression tests (Windows execution pending).
- [x] Retry an upgrade with an install when WinGet reports no matching installed package, preserving scope and testing bounded retries.
- [x] Make web config updates force replacement with backups by default, with an explicit opt-out.

View File

@ -103,11 +103,12 @@ Existing state, locks, backups, and logs are reused. An administrator prompt may
still be required for machine settings such as hosts. Close managed applications
first so they do not overwrite deployed settings on exit.
Local changes remain conflicts. To deliberately back them up and replace them
with the online versions:
The web updater defaults to `-ForceConfigs`: local settings are backed up and
replaced with the online versions. To preserve local edits and report conflicts
instead, explicitly disable force:
```powershell
& ([scriptblock]::Create((irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/update-configs.ps1'))) -ForceConfigs
& ([scriptblock]::Create((irm 'https://proxy.dandaedre.com/gitea/Beffroi/config-central/raw/branch/main/update-configs.ps1'))) -ForceConfigs:$false
```
A failed download makes no deployment changes. Partial deployment failures are

View File

@ -35,16 +35,20 @@ Describe 'Web config updater' {
Invoke-ConfigUpdate -DataRoot $TestDrive
$script:childArguments | Should -Contain '-ConfigsOnly'
$script:childArguments | Should -Contain ('a' * 40)
$script:childArguments | Should -Not -Contain '-ForceConfigs'
$script:childArguments | Should -Contain '-ForceConfigs'
@(Get-ChildItem $TestDrive -Directory -Filter 'config-central-update-*').Count | Should -Be 0
}
It 'allows explicitly preserving local edits' {
Invoke-ConfigUpdate -DataRoot $TestDrive -ForceConfigs:$false
$script:childArguments | Should -Not -Contain '-ForceConfigs'
}
It 'does not apply after a failed download' {
$script:gitFailure = $true
{ Invoke-ConfigUpdate -DataRoot $TestDrive } | Should -Throw '*download failed*'
Should -Invoke pwsh.exe -Times 0
@(Get-ChildItem $TestDrive -Directory -Filter 'config-central-update-*').Count | Should -Be 0
}
It 'surfaces partial failures and forwards only an explicit force request' {
It 'surfaces partial failures while forcing config deployment' {
$script:applyFailure = $true
{ Invoke-ConfigUpdate -DataRoot $TestDrive -ForceConfigs } | Should -Throw '*exit 5*'
$script:childArguments | Should -Contain '-ForceConfigs'

View File

@ -1,11 +1,11 @@
#requires -Version 5.1
[CmdletBinding()]
param(
[switch]$ForceConfigs
[switch]$ForceConfigs = $true
)
function Invoke-ConfigUpdate {
param([string]$DataRoot, [switch]$ForceConfigs)
param([string]$DataRoot, [switch]$ForceConfigs = $true)
$settingsPath = Join-Path $DataRoot 'settings.json'
if (-not (Test-Path -LiteralPath $settingsPath -PathType Leaf)) {
throw 'Run install.ps1 once on this computer before updating configs.'