views:

127

answers:

1

I'm trying to figure out a way to find out which files were affected by a work item in TFS 2008.

I realize that this is a duplication of a question already asked by someone else here - http://stackoverflow.com/questions/2219282/view-a-list-of-all-files-changed-as-part-of-a-workitem-in-tfs but it went unanswered and I've been, off and on, looking for this for a while.

I understand can view the links tab of the work item and then view each changeset to see the files that have been changed. But, the work item very likely will end up with many changesets linked to it, and I would like to review the files modified as part of the work item, but I feel like the likelihood of missing a file or two is very high if I have to rely on looking at each of the 100+ changesets individually.

Does anyone know of a way to accomplish this? Thanks in advance for any help or guidance.

+1  A: 

Sounds like a job for Powershell...

function Get-TfsItem([int] $workItemNumber)
{
    Get-TfsServer njtfs -all |
        foreach { $_.wit.GetWorkItem($workItemNumber) } |
        foreach { $_.Links } |
        foreach { ([regex]'vstfs:///VersionControl/Changeset/(\d+)').matches($_.LinkedArtifactUri) } |
        foreach { $_.groups[1].value } |
        Get-TfsChangeset | 
        Select-TfsItem |
        Sort Path -Unique 
}

The first several lines are kind of ugly. We have to hit the webservice API directly since the TFS cmdlets don't cover the bug tracking system. And the objects we get back require some regular expression love before they'll do what we need. Piping to "foreach" over & over is an unfortunate Powershell idiom that arises when you mate an unfriendly API to a lame projection operator. (I use my own replacement, personally, but you can't rely on that.)

The last 3 lines should be self explanatory if my TFS Power Cmdlets are installed & doing their job.

Richard Berg
I'll have to give that a try. Haven't used powershell before, got any tutorial links that you think are particularly good?
Billyhole