Skip to content

Commit

Permalink
Add work items as a value to GetWorkItemFiles cmdlet output
Browse files Browse the repository at this point in the history
  • Loading branch information
vbjay committed Sep 7, 2016
1 parent 05c5dac commit 18a6db0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 12 additions & 3 deletions TFS Release Notes/Cmdlets/GetWorkItemFiles.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ Public Class GetWorkItemFiles

Dim changes = changesets.SelectMany(Function(cs) cs.Changes)

Dim byItem = From c In changes Group By ServerPath = c.Item.ServerItem Into ItemChanges = Group
Select New FileChangeInfo With {.ServerPath = ServerPath, .Changes = ItemChanges, .LastCheckin = ItemChanges.Max(Function(c) c.Item.CheckinDate)}

Dim changesetWorkItems = changesets.Select(Function(cs) New With {.Changes = cs.Changes.Select(Function(c) c.Item.ItemId).ToArray, .WorkItems = cs.WorkItems})
WriteVerbose("Generating file change list...")
Dim byItem = (From c In changes Group By ServerPath = c.Item.ServerItem Into ItemChanges = Group
Select New FileChangeInfo With {.ServerPath = ServerPath,
.Changes = ItemChanges,
.LastCheckin = ItemChanges.Max(Function(ch) ch.Item.CheckinDate)}).ToList

WriteVerbose("List generated...")
For Each item In byItem
'Getting this value here because it is slow. It allows better progress than getting the value above.
item.WorkItems = changesetWorkItems.Where(Function(ch) item.Changes.Select(Function(ic) ic.Item.ItemId).Intersect(ch.Changes).Any).
SelectMany(Function(wc) wc.WorkItems).DistinctBy(Function(w) w.Id).ToArray

WriteObject(item)
Next

End Sub

End Class
3 changes: 3 additions & 0 deletions TFS Release Notes/Outputs/FileChangeInfo.vb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Imports Microsoft.TeamFoundation.VersionControl.Client
Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Public Class FileChangeInfo
Property Changes As IEnumerable(Of Change)
Property LastCheckin As Date
Property ServerPath As String
Property WorkItems As IEnumerable(Of WorkItem)
End Class

0 comments on commit 18a6db0

Please sign in to comment.