Skip to content

Commit

Permalink
Adds guard around Check-in to not throw errors when there are no chan…
Browse files Browse the repository at this point in the history
…ges to check in. Probably fixes #15,
  • Loading branch information
jessehouwing committed Feb 22, 2016
1 parent 64f5b43 commit 7793b61
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions extension-manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"manifestVersion": 1,
"id": "jessehouwing-vsts-tfvc-tasks-TEST",
"id": "jessehouwing-vsts-tfvc-tasks",
"name": "TFVC Build Tasks",
"version": "1.0.22",
"version": "1.0.23",
"publisher": "jessehouwing",
"public": false,
"public": true,
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
Expand Down
2 changes: 1 addition & 1 deletion vsts-tfvc-add/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 90
"Patch": 94
},
"minimumAgentVersion": "1.83.0",
"groups": [
Expand Down
32 changes: 20 additions & 12 deletions vsts-tfvc-checkin/TfvcCheckin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,31 @@ Try

$passed = [ref] $true

$evaluationOptions = [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"AddMissingFieldValues" -bor [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"Notes" -bor [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"Policies"
$result = Evaluate-Checkin $provider.Workspace $evaluationOptions $pendingChanges $pendingChanges $comment $CheckinNotes $null $passed
if ($pendingChanges.Length -gt 0)
{

$evaluationOptions = [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"AddMissingFieldValues" -bor [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"Notes" -bor [Microsoft.TeamFoundation.VersionControl.Client.CheckinEvaluationOptions]"Policies"
$result = Evaluate-Checkin $provider.Workspace $evaluationOptions $pendingChanges $pendingChanges $comment $CheckinNotes $null $passed

if (($passed -eq $false) -and $OverridePolicy)
{
$override = Handle-PolicyOverride $result.PolicyFailures $OverridePolicyReason $passed
}
if (($passed -eq $false) -and $OverridePolicy)
{
$override = Handle-PolicyOverride $result.PolicyFailures $OverridePolicyReason $passed
}

if ($override -eq $null -or $OverridePolicy)
{
Write-Verbose "Entering Workspace-Checkin"
$provider.Workspace.CheckIn($pendingChanges, $Comment, [Microsoft.TeamFoundation.VersionControl.Client.CheckinNote]$CheckinNotes, [Microsoft.TeamFoundation.VersionControl.Client.WorkItemCheckinInfo[]]$null, [Microsoft.TeamFoundation.VersionControl.Client.PolicyOverrideInfo]$override)
Write-Verbose "Leaving Workspace-Checkin"
if ($override -eq $null -or $OverridePolicy)
{
Write-Verbose "Entering Workspace-Checkin"
$provider.Workspace.CheckIn($pendingChanges, $Comment, [Microsoft.TeamFoundation.VersionControl.Client.CheckinNote]$CheckinNotes, [Microsoft.TeamFoundation.VersionControl.Client.WorkItemCheckinInfo[]]$null, [Microsoft.TeamFoundation.VersionControl.Client.PolicyOverrideInfo]$override)
Write-Verbose "Leaving Workspace-Checkin"
}
else
{
Write-Error "Checkin policy failed"
}
}
else
{
Write-Error "Checkin policy failed"
Write-Output "No changes to check in"
}
}
Finally
Expand Down
2 changes: 1 addition & 1 deletion vsts-tfvc-checkin/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 121
"Patch": 125
},
"visibility": [
"Build"
Expand Down

0 comments on commit 7793b61

Please sign in to comment.