Skip to content

Commit

Permalink
Add -Squash switch to Expand-Template.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Jul 10, 2019
1 parent 45cb59e commit e4753b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion Expand-Template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A token obtained from codecov.io for your repo. If not specified, code coverage
but can be added later by editing the Azure Pipelines YAML file.
.PARAMETER CIFeed
The `/{guid}` path to the Azure Pipelines artifact feed to push your nuget package to as part of your CI.
.PARAMETER Squash
A switch that causes all of git history to be squashed to just one initial commit for the template, and one for its expansion.
#>
[CmdletBinding()]
Param(
Expand All @@ -20,7 +22,9 @@ Param(
[Parameter()]
[string]$CodeCovToken,
[Parameter()]
[string]$CIFeed
[string]$CIFeed,
[Parameter()]
[switch]$Squash
)

function Replace-Placeholders {
Expand Down Expand Up @@ -69,6 +73,11 @@ if (-not $sn) {

Push-Location $PSScriptRoot
try {
if ($Squash) {
git reset --soft $(git rev-list --max-parents=0 HEAD)
git commit --amend -qm "Initial template from https://github.com/AArnott/Library.Template"
}

# Rename project directories and solution
Set-Location src
git mv Library.sln "$LibraryName.sln"
Expand Down Expand Up @@ -147,6 +156,9 @@ try {
Write-Error "PLACEHOLDER discovered in $($_.FullName)"
}
}

# Commit the changes
git commit -qm "Expanded template for $LibraryName" -m "This expansion done by the (now removed) Expand-Template.ps1 script."
} finally {
Pop-Location
}
Expand Down
5 changes: 4 additions & 1 deletion azure-pipelines/expand-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ steps:
dotnet build-server shutdown
git clean -fdx
displayName: Cleaning repo for template expansion
- powershell: ./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott"
- powershell: |
git config user.name "test user"
git config user.email "[email protected]"
./Expand-Template.ps1 -LibraryName Calc -Author "Andrew Arnott"
displayName: Expanding template
failOnStderr: true
# TODO: Verify that all changes are staged to the git index
Expand Down

0 comments on commit e4753b7

Please sign in to comment.