Add some intelligence to Copy-MappedFiles

This commit is contained in:
Sergei Vorobev 2016-06-13 18:46:15 -07:00
parent 41ebec2ef1
commit 029086e27c
2 changed files with 57 additions and 4 deletions

View File

@ -657,17 +657,70 @@ function Copy-MappedFiles {
[Parameter(ValueFromPipeline=$true)]
[string[]]$Path = "$PSScriptRoot",
[Parameter(Mandatory=$true)]
[string]$PslMonadRoot
[string]$PslMonadRoot,
[switch]$Force
)
begin
{
function MaybeTerminatingWarning
{
param([string]$Message)
if ($Force)
{
Write-Warning "$Message : ignoring (-Force)"
}
else
{
throw "$Message : use -Force to ignore"
}
}
if (-not (Test-Path -PathType Container $PslMonadRoot))
{
throw "$pslMonadRoot is not a valid folder"
}
$map = @()
# Do some intelligens to prevent shouting us in the foot with CL management
# finding base-line CL
$cl = git tag | % {if ($_ -match 'SD.(\d+)$') {[int]$Matches[1]} } | sort -Descending | select -First 1
if ($cl)
{
Write-Host -ForegroundColor Green "Current base-line CL is SD:$cl (based on tags)"
}
else
{
MaybeTerminatingWarning "Could not determine base-line CL based on tags"
}
try
{
Push-Location $PslMonadRoot
if (git status --porcelain)
{
MaybeTerminatingWarning "$pslMonadRoot has changes"
}
if (git log --grep="SD:$cl" HEAD^..HEAD)
{
Write-Host -ForegroundColor Green "$pslMonadRoot HEAD matches [SD:$cl]"
}
else
{
Write-Host -ForegroundColor Yellow "Try to checkout this commit in $pslMonadRoot :"
git log --grep="SD:$cl"
MaybeTerminatingWarning "$pslMonadRoot HEAD doesn't match [SD:$cl]"
}
}
finally
{
Pop-Location
}
$map = @{}
}
process

View File

@ -65,7 +65,7 @@ If you are creating new folder for that, create `map.json` with all mapped files
```
> git tag
SD-692351 <--- the last changelist
SD-692351
SD-693793
SD/688741
SD/692351
@ -74,7 +74,7 @@ SD/695331
SD/700586
SD/704605
SD/706766
SD/709766
SD/709766 <--- the last changelist
v0.1.0
v0.2.0
v0.3.0