diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a7be2b4c9..7876dc22e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -19,6 +19,7 @@ jobs: architecture: 'x64' - script: | + powershell.exe scripts/symlinks-to-hardlinks.ps1 "C:\Program Files\Git\mingw64\bin\curl.exe" -sSf -o rustup-init.exe https://win.rustup.rs/ .\rustup-init.exe -y set PATH=%PATH%;%USERPROFILE%\.cargo\bin diff --git a/redox/comment-cargo.sh b/scripts/redox/comment-cargo.sh similarity index 100% rename from redox/comment-cargo.sh rename to scripts/redox/comment-cargo.sh diff --git a/redox/install.sh b/scripts/redox/install.sh similarity index 100% rename from redox/install.sh rename to scripts/redox/install.sh diff --git a/redox/recipe.sh b/scripts/redox/recipe.sh similarity index 100% rename from redox/recipe.sh rename to scripts/redox/recipe.sh diff --git a/redox/uncomment-cargo.sh b/scripts/redox/uncomment-cargo.sh similarity index 100% rename from redox/uncomment-cargo.sh rename to scripts/redox/uncomment-cargo.sh diff --git a/scripts/symlinks-to-hardlinks.ps1 b/scripts/symlinks-to-hardlinks.ps1 new file mode 100644 index 000000000..77ffe0d61 --- /dev/null +++ b/scripts/symlinks-to-hardlinks.ps1 @@ -0,0 +1,28 @@ +#!/usr/bin/env powershell +git ls-files -s | Select-String '^120000' | ConvertFrom-String -PropertyNames Get-Content,Hash,_,Path | ForEach-Object { + $symlink = $_.Path + + git checkout --quiet -- $symlink + if (Test-Path $symlink -PathType Leaf) { + $parent = (Get-Item $symlink).Directory + } else { + $parent = (Get-Item $symlink).Parent + } + $child = (Get-Content $symlink) + + $src = (Join-Path -Path $parent -ChildPath $child) + + if (Test-Path $src -PathType Leaf) { + Remove-Item $symlink + New-Item -ItemType HardLink -Name $symlink -Value $src + } elseif (Test-Path $src -PathType Container) { + Remove-Item $symlink + New-Item -ItemType Junction -Name $symlink -Value $src + } else { + Write-Error 'error: git-rm-symlink: Not a valid source\n' + Write-Error '$symlink =/=> $src...' + return + } + + git update-index --assume-unchanged $symlink +}