@@ -325,9 +325,12 @@ if ($name) {
325
325
$version_file_backed_up = 0
326
326
# Force use of a backup if there are pending changes to $version_file
327
327
$version_file_force_backup = 0
328
- if (-not (tf status $version_file / format:detailed | Select-String " There are no pending changes." )) {
329
- Write-Output " $version_file has pending changes. Using backup instead of tf undo."
330
- $version_file_force_backup = 1
328
+ $has_tf_workspace = (-not (tf workspaces | Select-String - pattern " No workspace" , " Unable to determine the workspace" ))
329
+ if ($has_tf_workspace ) {
330
+ if (-not (tf status $version_file / format:detailed | Select-String " There are no pending changes." )) {
331
+ Write-Output " $version_file has pending changes. Using backup instead of tf undo."
332
+ $version_file_force_backup = 1
333
+ }
331
334
}
332
335
$version_file_is_readonly = $version_file.Attributes -band [io.FileAttributes ]::ReadOnly
333
336
@@ -433,7 +436,7 @@ if (-not $skipclean) {
433
436
434
437
$logdir = mkdir " $outdir \Logs" - Force
435
438
436
- if ($scorch ) {
439
+ if ($scorch -and $has_tf_workspace ) {
437
440
tfpt scorch $buildroot / noprompt
438
441
}
439
442
@@ -442,7 +445,7 @@ $failed_logs = @()
442
445
Push-Location $buildroot
443
446
try {
444
447
$successful = $false
445
- if (-not $version_file_force_backup ) {
448
+ if (( -not $version_file_force_backup ) -and $has_tf_workspace ) {
446
449
tf edit $version_file | Out-Null
447
450
}
448
451
if ($version_file_force_backup -or -not $? ) {
@@ -636,7 +639,7 @@ try {
636
639
Set-ItemProperty $version_file - Name IsReadOnly - Value $true
637
640
}
638
641
Write-Output " Restored $version_file "
639
- } elseif (-not $version_file_force_backup ) {
642
+ } elseif (( -not $version_file_force_backup ) -and $has_tf_workspace ) {
640
643
tf undo / noprompt $version_file | Out-Null
641
644
}
642
645
0 commit comments