Skip to content

Commit 9e096ed

Browse files
Copilotigoravl
andauthored
Fix Set-TfsWorkItem Fields parameter error by using actual work item ID (#246)
* Initial plan for issue * Fix Set-TfsWorkItem Fields parameter issue by using actual work item ID Co-authored-by: igoravl <[email protected]> * Add support for version "20" * Update tests * Update release notes * Fixes double-confirmation in Remove-TfsTeamProject * Add missing ShouldProcess support * Update release notes --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: igoravl <[email protected]> Co-authored-by: Igor Abade <[email protected]>
1 parent 4b27cde commit 9e096ed

File tree

10 files changed

+52
-46
lines changed

10 files changed

+52
-46
lines changed

CSharp/TfsCmdlets/Cmdlets/TeamProject/RemoveTeamProject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ protected override IEnumerable Run()
4949
{
5050
if (!PowerShell.ShouldProcess($"[Organization: {tpc.DisplayName}]/[Project: {tp.Name}]", "Delete team project")) continue;
5151

52-
if (!force && !PowerShell.ShouldContinue($"Are you sure you want to delete team project '{tp.Name}'?")) continue;
52+
if (!(force || PowerShell.ShouldContinue($"Are you sure you want to delete team project '{tp.Name}'?"))) continue;
5353

54-
if (hard && !PowerShell.ShouldContinue(
54+
if (hard && !(force || PowerShell.ShouldContinue(
5555
"You are using the -Hard switch. The team project deletion is IRREVERSIBLE " +
56-
$"and may cause DATA LOSS. Are you sure you want to proceed with deleting team project '{tp.Name}'")) continue;
56+
$"and may cause DATA LOSS. Are you sure you want to proceed with deleting team project '{tp.Name}'"))) continue;
5757

5858
var method = hard ? "Hard" : "Soft";
5959

CSharp/TfsCmdlets/Cmdlets/WorkItem/SetWorkItem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ protected override IEnumerable Run()
154154
{
155155
foreach (var wi in Items)
156156
{
157+
if(!PowerShell.ShouldProcess(
158+
$"Work item {wi.Id} (\"{wi.Fields["System.Title"] ?? "No title"}\")",
159+
"Update work item"))
160+
{
161+
continue;
162+
}
163+
157164
var result = Client.UpdateWorkItemAsync(Builder.GetJson(wi), (int)wi.Id, false, BypassRules, SuppressNotifications)
158165
.GetResult("Error updating work item");
159166

CSharp/TfsCmdlets/Services/Impl/TfsVersionTableImpl.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public bool IsMajorVersion(int majorVersion)
205205
[17] = 2019,
206206
[18] = 2020,
207207
[19] = 2022,
208+
[20] = 2022,
208209
};
209210
}
210211
}

CSharp/TfsCmdlets/Services/Impl/WorkItemPatchBuilderImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public JsonPatchDocument GetJson(WebApiWorkItem wi)
3636

3737
if (fields != null && fields.Count > 0)
3838
{
39-
var wit = Data.GetItem<WebApiWorkItemType>(new { Type = wi.Fields["System.WorkItemType"], WorkItem = 0, Project = projectName });
39+
var wit = Data.GetItem<WebApiWorkItemType>(new { Type = wi.Fields["System.WorkItemType"], WorkItem = wi.Id, Project = projectName });
4040
patch.AddRange(ParseFields(fields, wit, projectName, workItemType));
4141
}
4242

Docs/ReleaseNotes/2.9.1.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# TfsCmdlets Release Notes
2+
3+
## Version 2.9.1 (_05/Jun/2025_)
4+
5+
This release fixes a critical bug in Set-TfsWorkItem, among other improvements.
6+
7+
## Fixes
8+
9+
- **`Get-TfsVersion`**: Adds support for Azure DevOps Services version "20" (currently mapped to 2022)
10+
- **`Remove-TfsTeamProject`**: Removes a double-confirmation prompt when using the `-Hard` switch, simplifying the deletion process
11+
- **`Set-TfsWorkItem`**: Fixed an issue where the actual work item ID wasn't being used when retrieving work item type information, causing some field updates to fail

PS/_Tests/RestApi/InvokeTfsRestApi.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Describe (($MyInvocation.MyCommand.Name -split '\.')[-3]) {
1616
| ForEach-Object { $_.ExtensionName } `
1717
| Sort-Object `
1818
| Select-Object -First 3 `
19-
| Should -Be @('AdvancedSecurity', 'Aex Code Mapper', 'Aex platform')
19+
| Should -Be @('AdvancedSecurity', 'AdvancedSecurity Alerts', 'Aex Code Mapper')
2020
}
2121

2222
It 'Should call multiple alternates hosts in sequence' {
2323
Invoke-TfsRestApi '/_apis/extensionmanagement/installedextensions' -UseHost 'extmgmt.dev.azure.com' -ApiVersion '6.1' `
2424
| ForEach-Object { $_.ExtensionName } `
2525
| Sort-Object `
2626
| Select-Object -First 3 `
27-
| Should -Be @('AdvancedSecurity', 'Aex Code Mapper', 'Aex platform')
27+
| Should -Be @('AdvancedSecurity', 'AdvancedSecurity Alerts', 'Aex Code Mapper')
2828

2929
Invoke-TfsRestApi 'GET https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?api-version=6.1' -Project $tfsProject `
3030
| ForEach-Object { $_.name } `

PS/_Tests/Team/TeamAdmin/GetTfsTeamAdmin.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ Describe (($MyInvocation.MyCommand.Name -split '\.')[-3]) {
1313
It 'Should return all team admins' {
1414
$result = Get-TfsTeamAdmin -Project $tfsProject -Team "$tfsProject Team"
1515
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
16-
$result.DisplayName | Sort-Object | Should -Be @('Igor Abade (T-Shooter)')
16+
$result.DisplayName | Sort-Object | Should -Be @('Igor Abade')
1717
}
1818

1919
It 'Should return a single team admin by name' {
20-
$result = Get-TfsTeamAdmin -Admin 'Igor Abade (T-Shooter)' -Project $tfsProject -Team "$tfsProject Team"
20+
$result = Get-TfsTeamAdmin -Admin 'Igor Abade' -Project $tfsProject -Team "$tfsProject Team"
2121
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
22-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
22+
$result.DisplayName | Should -Be 'Igor Abade'
2323
}
2424

2525
It 'Should return a single team admin by email' {
2626
$result = Get-TfsTeamAdmin -Admin '[email protected]' -Project $tfsProject -Team "$tfsProject Team"
2727
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
28-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
28+
$result.DisplayName | Should -Be 'Igor Abade'
2929
}
3030

3131
It 'Should support wildcards' {
3232
$result = Get-TfsTeamAdmin -Project $tfsProject -Team "$tfsProject Team" -Admin 'Igor A*'
3333
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
34-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
34+
$result.DisplayName | Should -Be 'Igor Abade'
3535
$result = Get-TfsTeamAdmin -Project $tfsProject -Team "$tfsProject Team" -Admin 'igor@*'
3636
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
37-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
37+
$result.DisplayName | Should -Be 'Igor Abade'
3838
}
3939
}
4040
}

PS/_Tests/Team/TeamMember/GetTfsTeamMember.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ Describe (($MyInvocation.MyCommand.Name -split '\.')[-3]) {
1313
It 'Should return all team members' {
1414
$result = Get-TfsTeamMember -Project $tfsProject -Team "$tfsProject Team"
1515
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
16-
$result.DisplayName | Sort-Object | Should -Be @('Brian Keller', 'Igor Abade (T-Shooter)')
16+
$result.DisplayName | Sort-Object | Should -Be @('Brian Keller', 'Igor Abade')
1717
}
1818

1919
It 'Should return a single team member by name' {
20-
$result = Get-TfsTeamMember -Member 'Igor Abade (T-Shooter)' -Project $tfsProject -Team "$tfsProject Team"
20+
$result = Get-TfsTeamMember -Member 'Igor Abade' -Project $tfsProject -Team "$tfsProject Team"
2121
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
22-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
22+
$result.DisplayName | Should -Be 'Igor Abade'
2323
}
2424

2525
It 'Should return a single team member by email' {
2626
$result = Get-TfsTeamMember -Member '[email protected]' -Project $tfsProject -Team "$tfsProject Team"
2727
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
28-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
28+
$result.DisplayName | Should -Be 'Igor Abade'
2929
}
3030

3131
It 'Should support wildcards' {
3232
$result = Get-TfsTeamMember -Project $tfsProject -Team "$tfsProject Team" -Member 'Igor A*'
3333
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
34-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
34+
$result.DisplayName | Should -Be 'Igor Abade'
3535
$result = Get-TfsTeamMember -Project $tfsProject -Team "$tfsProject Team" -Member 'igor@*'
3636
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
37-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
37+
$result.DisplayName | Should -Be 'Igor Abade'
3838
}
3939
}
4040
}

PS/_Tests/TeamProject/Member/GetTfsTeamProjectMember.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Describe (($MyInvocation.MyCommand.Name -split '\.')[-3]) {
1313
It 'Should return all members' {
1414
$result = Get-TfsTeamProjectMember -Project $tfsProject
1515
$result | Should -BeOfType 'TfsCmdlets.Models.TeamProjectMember'
16-
$result.Name | Sort-Object | Should -Be @('Brian Keller', 'Igor Abade (T-Shooter)')
16+
$result.Name | Sort-Object | Should -Be @('Brian Keller', 'Igor Abade')
1717
}
1818

1919
It 'Should return a single member by name' {
20-
$result = Get-TfsTeamProjectMember -Member 'Igor Abade (T-Shooter)' -Project $tfsProject
20+
$result = Get-TfsTeamProjectMember -Member 'Igor Abade' -Project $tfsProject
2121
$result | Should -BeOfType 'TfsCmdlets.Models.TeamProjectMember'
22-
$result.Name | Should -Be 'Igor Abade (T-Shooter)'
22+
$result.Name | Should -Be 'Igor Abade'
2323
}
2424

2525
It 'Should return a single member by email' {
2626
$result = Get-TfsTeamProjectMember -Member '[email protected]' -Project $tfsProject
2727
$result | Should -BeOfType 'TfsCmdlets.Models.TeamProjectMember'
28-
$result.Name | Should -Be 'Igor Abade (T-Shooter)'
28+
$result.Name | Should -Be 'Igor Abade'
2929
}
3030

3131
It 'Should support wildcards' {
@@ -38,9 +38,9 @@ Describe (($MyInvocation.MyCommand.Name -split '\.')[-3]) {
3838
}
3939

4040
It 'Should return as identity' {
41-
$result = Get-TfsTeamProjectMember 'Igor Abade (T-Shooter)' -Project $tfsProject -AsIdentity
41+
$result = Get-TfsTeamProjectMember 'Igor Abade' -Project $tfsProject -AsIdentity
4242
$result | Should -BeOfType 'Microsoft.VisualStudio.Services.Identity.Identity'
43-
$result.DisplayName | Should -Be 'Igor Abade (T-Shooter)'
43+
$result.DisplayName | Should -Be 'Igor Abade'
4444
}
4545
}
4646
}

RELEASENOTES.md

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,23 @@
11
# TfsCmdlets Release Notes
22

3-
## Version 2.9.0 (15/Aug/2024_)
3+
## Version 2.9.1 (_05/Jun/2025_)
44

5-
This release adds new process-related cmdlets along with some fixes, enhancements and a couple minor but potentially breaking changes.
6-
7-
## New cmdlets
8-
9-
- **`Get-ProcessFieldDefinition`**: Gets information from one or more organization-wide work item fields
10-
- **`New-ProcessFieldDefinition`**: Creates a new organization-wide work item field
11-
- **`Remove-ProcessFieldDefinition`**: Removes an organization-wide work item field
5+
This release fixes a critical bug in Set-TfsWorkItem, among other improvements.
126

137
## Fixes
148

15-
- **`Get-TfsArtifact`**: Fixed an issue where it wouldn't list deleted packages.
16-
- **`Get-TfsArtifactFeed`**: Fixed an issue where it would ignore the -Project argument and thus not filter feeds by project.
17-
- **`Get-TfsWorkItemTag`**: Fixed an issue where it would fail when given a list of tags as input.
18-
- **`Get-TfsWorkItemType`**: Fixed an issue where it would throw a "Parameter count mismatch" error when trying to get the work item type of a given work item.
19-
20-
## Changes and enhancements
21-
22-
- **`Get-TfsGitBranch`**: Added a new `-Compare` argument to to get the "Compare" (base) branch of a given repository.
23-
- **`Connect-TfsTeamProjectCollection`, `Connect-TfsOrganization`**: Now it throws an error when trying to connect with invalid credentials instead of silently going into "anonymous mode". That help preventing subtle script errors where the lack of authorization would only be noticed later in the script, when trying to actually perform some command that required valid credentials. Now you get the warning that something is wrong as early in the script as possible.
24-
25-
### Breaking changes
26-
27-
- **`Get-TfsGitBranch`**: `-Repository` parameter is now mandatory. This is to reduce the ambiguity of the command when omitting that argument. Scripts that rely on the old behavior may need to be updated.
28-
- **`Get-TfsGitBranchPolicy`**: Both `-Branch` and `-Repository` parameters are now mandatory. This is to reduce the ambiguity of the command when omitting those arguments. Scripts that rely on the old behavior may need to be updated.
9+
- **`Get-TfsVersion`**: Adds support for Azure DevOps Services version "20" (currently mapped to 2022)
10+
- **`Remove-TfsTeamProject`**: Removes a double-confirmation prompt when using the `-Hard` switch, simplifying the deletion process
11+
- **`Set-TfsWorkItem`**: Fixed an issue where the actual work item ID wasn't being used when retrieving work item type information, causing some field updates to fail
2912

3013
-----------------------
3114

3215
## Previous Versions
3316

17+
## Version 2.9.0 (_15/Aug/2024_)
18+
19+
See release notes [here](Docs/ReleaseNotes/2.9.0.md).
20+
3421
## Version 2.8.2 (_24/Jul/2024_)
3522

3623
See release notes [here](Docs/ReleaseNotes/2.8.2.md).

0 commit comments

Comments
 (0)