diff options
| author | srdusr <trevorgray@srdusr.com> | 2024-06-05 19:07:12 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2024-06-05 19:07:12 +0200 |
| commit | 5c3e62218ad7e0ef8e35d5e56948025ddc1f2b19 (patch) | |
| tree | 7f374a0a12ea2932a7c626a097ba5ea5a26bd774 | |
| parent | db0a5bb74d76033710269506c6941a4d27633b6d (diff) | |
| download | dotfiles-5c3e62218ad7e0ef8e35d5e56948025ddc1f2b19.tar.gz dotfiles-5c3e62218ad7e0ef8e35d5e56948025ddc1f2b19.zip | |
Testing
| -rw-r--r-- | .config/powershell/initialize.ps1 | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/.config/powershell/initialize.ps1 b/.config/powershell/initialize.ps1 index 464f245..f30bb14 100644 --- a/.config/powershell/initialize.ps1 +++ b/.config/powershell/initialize.ps1 @@ -88,13 +88,37 @@ function cloneDotfiles { } Add-Content -Path "$env:USERPROFILE\.gitignore" -Value ".cfg" + + if (Test-Path -Path $dotfiles_dir) { + config pull | Out-Null + $update = $true + } else { + git clone --bare $dotfiles_url $dotfiles_dir | Out-Null + $update = $false + } + $std_err_output = config checkout 2>&1 + if ($std_err_output -match "following untracked working tree files would be overwritten") { - Write-Warning "Some untracked files will be overwritten. Aborting." - return 5 + if (-not $update) { + config checkout | Out-Null + } } - config config --local status.showUntrackedFiles no + + if ($update -or (Read-Host "Do you want to overwrite existing files and continue with the dotfiles setup? [Y/n]" -eq "Y")) { + config fetch origin main:main | Out-Null + config reset --hard main | Out-Null + config checkout -f + if ($?) { + Write-Host "Successfully imported $dotfiles_dir." + } else { + handle_error "Mission failed." + } + } else { + handle_error "Aborted by user. Exiting..." + } + return 0 } |
