diff --git a/scripts/Rewrite-GitHostUrls.ps1 b/scripts/Rewrite-GitHostUrls.ps1 index 44c3e20..5df7706 100644 --- a/scripts/Rewrite-GitHostUrls.ps1 +++ b/scripts/Rewrite-GitHostUrls.ps1 @@ -1,4 +1,4 @@ -# Rewrite cross-repo URLs in tracked docs/config for the target Git host. +# Rewrite cross-repo URLs in tracked docs/config for the target Git host. # Usage: .\scripts\Rewrite-GitHostUrls.ps1 github|kalinamall|papatramp param( [Parameter(Mandatory = $true)] @@ -28,12 +28,12 @@ switch ($Target) { $BaseHost = $Base -replace '^https://', '' $patterns = @( - @{ From = 'https://github.com/PTah/([^)/''"\s]+)/blob/main/'; To = "$Base/`$1$BlobSuffix/" } - @{ From = 'https://github.com/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } - @{ From = 'https://git.kalinamall.ru/PapaTramp/([^)/''"\s]+)/blob/main/'; To = "$Base/`$1$BlobSuffix/" } - @{ From = 'https://git.kalinamall.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } - @{ From = 'https://git.papatramp.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } - @{ From = 'https://git.papatramp.ru/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`$1$BlobSuffix/" } + @{ From = 'https://github.com/PTah/([^)/''"\s]+)/blob/main/'; To = "$Base/`${1}$BlobSuffix/" } + @{ From = 'https://github.com/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" } + @{ From = 'https://git.kalinamall.ru/PapaTramp/([^)/''"\s]+)/blob/main/'; To = "$Base/`${1}$BlobSuffix/" } + @{ From = 'https://git\.kalinamall\.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" } + @{ From = 'https://git.papatramp.ru/PapaTramp/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" } + @{ From = 'https://git.papatramp.ru/PTah/([^)/''"\s]+)/src/branch/main/'; To = "$Base/`${1}$BlobSuffix/" } @{ From = 'https://github.com/PTah/'; To = "$Base/" } @{ From = 'https://git.kalinamall.ru/PapaTramp/'; To = "$Base/" } @{ From = 'https://git.papatramp.ru/PapaTramp/'; To = "$Base/" } diff --git a/scripts/Sanitize-ForGitHub.ps1 b/scripts/Sanitize-ForGitHub.ps1 index c5a3f30..cf54a72 100644 --- a/scripts/Sanitize-ForGitHub.ps1 +++ b/scripts/Sanitize-ForGitHub.ps1 @@ -152,4 +152,18 @@ if (Test-Path -LiteralPath $netlogonDoc) { Set-TrackedFileText -RelativePath 'Docs/deploy-netlogon-publish.md' -Content $doc } +$mdFiles = @(git ls-files '*.md' 2>$null | Where-Object { $_ -and (Test-Path $_) }) +foreach ($rel in $mdFiles) { + $path = Join-Path $Root $rel + $md = Get-Content -LiteralPath $path -Raw + $orig = $md + $md = $md -replace 'https://git\.kalinamall\.ru/PapaTramp/([^)/\s]+)/src/branch/main/', 'https://github.com/PTah/$1/blob/main/' + $md = $md -replace 'https://git\.papatramp\.ru/PapaTramp/([^)/\s]+)/src/branch/main/', 'https://github.com/PTah/$1/blob/main/' + $md = $md -replace 'https://git\.kalinamall\.ru/PapaTramp/', 'https://github.com/PTah/' + $md = $md -replace 'https://git\.papatramp\.ru/PapaTramp/', 'https://github.com/PTah/' + if ($md -ne $orig) { + Set-TrackedFileText -RelativePath $rel -Content $md + } +} + Write-Output 'Sanitize-ForGitHub: done' diff --git a/scripts/Test-NoSecretsForGitHub.ps1 b/scripts/Test-NoSecretsForGitHub.ps1 index badceb5..3be6adc 100644 --- a/scripts/Test-NoSecretsForGitHub.ps1 +++ b/scripts/Test-NoSecretsForGitHub.ps1 @@ -28,6 +28,7 @@ foreach ($file in $files) { if ($file -like 'scripts/Sanitize-ForGitHub.ps1') { continue } if ($file -like 'scripts/Test-NoSecretsForGitHub.ps1') { continue } if ($file -like 'scripts/Push-GitHubMirror.ps1') { continue } + if ($file -like 'scripts/Push-Mirror.ps1') { continue } $text = Get-Content -LiteralPath $file -Raw -ErrorAction SilentlyContinue if ([string]::IsNullOrEmpty($text)) { continue }