feat(windows): добавлен chezmoi-слой для pwsh, terminal и git

- Зачем:
  - нужно перенести стабильную Windows-конфигурацию в dotfiles без поломки существующего stow/install.sh workflow для Linux и WSL.
  - нужно убрать типичные проблемы Git на Windows, включая line endings, из ручной настройки машины.
- Что:
  - добавлен отдельный source dir `chezmoi/` с tiny stub для PowerShell 7 и managed profile в `~/.config/powershell`.
  - добавлены идемпотентная настройка Windows Terminal и managed Git baseline с миграцией локальных настроек в `~/.gitconfig.local`.
  - обновлён README: описан Windows workflow, helper-функции pwsh и состав Git baseline без персональных данных.
- Проверка:
  - `chezmoi -S "$HOME\dotfiles\chezmoi" apply`
  - `pwsh -NoLogo -Command ''$PSVersionTable.PSVersion.ToString(); chcp; [Console]::InputEncoding.WebName; [Console]::OutputEncoding.WebName''`
  - `git config --global --includes --list --show-origin`
This commit is contained in:
Dmitry Dementiev committed 2026-03-22 15:45:08 +03:00
1 parent 22d38f80e5
commit 8fd5b9c630
8 files changed
+750 -238

No files matched your search

@@ -0,0 +1,67 @@
if (-not $IsWindows) {
return
}
$GlobalGitConfig = Join-Path $HOME '.gitconfig'
$LocalGitConfig = Join-Path $HOME '.gitconfig.local'
$BackupPath = '{0}.pre-chezmoi.bak-{1}' -f $GlobalGitConfig, (Get-Date -Format 'yyyyMMdd-HHmmss')
$ManagedStub = @'
[include]
path = ~/.config/git/config
[include]
path = ~/.gitconfig.local
'@
$ManagedKeys = @(
'core.autocrlf',
'core.eol',
'core.quotepath',
'core.longpaths',
'fetch.prune',
'pull.ff',
'init.defaultBranch'
)
function Test-ManagedGitStub {
param(
[Parameter(Mandatory = $true)]
[string]$Content
)
$NormalizedContent = ($Content -replace "`r", '').Trim()
$NormalizedStub = ($ManagedStub -replace "`r", '').Trim()
return $NormalizedContent -eq $NormalizedStub
}
if (-not (Test-Path -LiteralPath $GlobalGitConfig)) {
if (-not (Test-Path -LiteralPath $LocalGitConfig)) {
New-Item -ItemType File -Path $LocalGitConfig -Force | Out-Null
}
return
}
$CurrentContent = Get-Content -LiteralPath $GlobalGitConfig -Raw
if (Test-ManagedGitStub -Content $CurrentContent) {
if (-not (Test-Path -LiteralPath $LocalGitConfig)) {
New-Item -ItemType File -Path $LocalGitConfig -Force | Out-Null
}
return
}
if (-not (Test-Path -LiteralPath $LocalGitConfig)) {
Copy-Item -LiteralPath $GlobalGitConfig -Destination $BackupPath -Force
Copy-Item -LiteralPath $GlobalGitConfig -Destination $LocalGitConfig -Force
foreach ($Key in $ManagedKeys) {
git config --file $LocalGitConfig --unset-all $Key 2>$null
}
Write-Host "Migrated existing ~/.gitconfig to ~/.gitconfig.local"
Write-Host "Backup saved to: $BackupPath"
return
}
Copy-Item -LiteralPath $GlobalGitConfig -Destination $BackupPath -Force
Write-Warning "~/.gitconfig.local already exists; current ~/.gitconfig was backed up before managed stub overwrite."
Write-Host "Backup saved to: $BackupPath"