Skip to content

Commit

Permalink
Protect against misapplication of the Apply-Template script
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Apr 14, 2022
1 parent 0ac22f8 commit 19515d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Apply-Template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ Param(
[string]$Path
)

Push-Location $Path
try {
# Look for our own initial commit in the target repo's history.
# If it's there, they've already switched to using git merge to freshen up.
# Using Apply-Template would just complicate future merges, so block it.
git log 05f49ce799c1f9cc696d53eea89699d80f59f833 ^HEAD | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Error 'The target repo already has Library.Template history merged into it. Use `git merge` instead of this script to freshen your repo. See the README.md file for details.'
exit 1
}
} finally {
Pop-Location
}

Write-Host "Updating $Path"
robocopy /mir $PSScriptRoot/azure-pipelines $Path/azure-pipelines
robocopy /mir $PSScriptRoot/.devcontainer $Path/.devcontainer
Expand Down

0 comments on commit 19515d7

Please sign in to comment.