15

In Team Foundation Server, I know that you can use the Annotate feature to see who last edited each line in a particular file (equivalent to "Blame" in CVS). What I'd like to do is akin to running Annotate on every file in a project, and get a summary report of all the developers who have edited a file in the project, and how many lines of code they currently "own" in that project.

Aside from systematically running Annotate of each file, I can't see a way to do this. Any ideas that would make this process faster?

PS - I'm doing to this to see how much of a consultant's code still remains in a particular (rather large) project, not to keep tabs on my developers, in case you're worried about my motivation :)

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
SqlRyan
  • 33,116
  • 33
  • 114
  • 199
  • http://blogs.msdn.com/buckh/archive/2006/03/13/annotate.aspx – Christopher Klein May 13 '09 at 14:46
  • thanks, @SqlRyan did you make the tool? – Quincy Jul 28 '15 at 13:48
  • @Quincy Wow, I can't believe this was 7 years ago - I've moved into a DBA role and I'm no longer a developer, so it turns out this actually was the last time I was going to have to do this :) That said, it is still interesting and on the list, but I never did end up making a utility that did it. It may even be native functionality now that they've had 4(?) more releases since this question was asked! – SqlRyan Jul 28 '15 at 20:35
  • Yeah your right. There is an excel report that has this functionality. Requires on-prem tfs but it works! – Quincy Jul 28 '15 at 20:36
  • @Quincy It would be great if *someone* shared a complete answer to this. ;-) How does your Excel report work? – jpaugh Jan 23 '17 at 15:32
  • @jpaugh in VS open team explorer then select "Documents" then explode "Excel Reports". I believe Code Churn report has something like discussed. The report is made by some default project template so I think tfs2013 on prem just creates it. – Quincy Jan 23 '17 at 18:06
  • @Quincy Thanks! It appears that I don't have access to that atm, and I have no current need for it. But, your latest comment is now the most useful part of this thread. When you have time to make a full answer, it would be worthwhile. – jpaugh Jan 23 '17 at 18:10
  • done. i feel like on prem excel reports are going away since they aren't supported with VSO. So in a couple more years there'll be another new way of doing things. – Quincy Jan 23 '17 at 18:46

6 Answers6

17

It's easy enough to use the "tf.exe history" command recursively across a directory of files in TFS. This will tell you who changed what files.

However what you're after is a little bit more than this - you want to know if the latest versions of any files have lines written by a particular user.

The Team Foundation Power Tools ship with a command-line version of annotate called "tfpt.exe annotate". This has a /noprompt option to direct the output to the console, but it only outputs the changeset id - not the user name.

You could also use the TFS VersionControl object model to write a tool that does exactly what you need.

granth
  • 8,919
  • 1
  • 43
  • 60
  • This seems close to what I'd like to do, though I'll still have to do the aggregating myself. I'll probably use this code as a springboard to write my own tool, actually, since I doubt this is the last time I'll have to do this. – SqlRyan Sep 17 '08 at 23:09
  • @SqlRyan Did you end up writing a console app/tool to do this? If so, could you share it? – mellis481 May 06 '16 at 13:08
  • `tf history filename` popped up a "History of filename" modal for me. Did this produce output to the command line for you? (realizing this is an answer from 12 years ago) – ruffin Aug 19 '20 at 15:31
1

Annotate is now part of Visual Studio (I think it was introduced in VS 2010).

Docs

Alexander
  • 23,432
  • 11
  • 63
  • 73
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154
1

You can use TFS Analysis Cube to see generate a code churn report, which I believe is something you would like.

e-mre
  • 3,305
  • 3
  • 30
  • 46
1

If you install the TFS Power tools (at least for VS2005); it's called annotate.

It might be part of VS2008...

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
0

I'm writing an answer to an 8 year old question :). Its not really a full answer, but a suggestion to look into excel reports for TFS.

TFS2013 / 2015 on prem has something has an excel report that can be used to visualize Code Churn.

In VS open team explorer then select "Documents" then explode "Excel Reports". I believe Code Churn report has something like discussed. The report is made by some default project template so I think tfs2013 on prem just creates it.

Code Churn Excel Report VS2015 https://msdn.microsoft.com/en-us/library/dd695782.aspx

Quincy
  • 1,710
  • 14
  • 20
0

I had very similar requirement to get details of particular attribute in a file e.g. who added, when, related work items etc.; Following GitHub project is having implementation to get required details and required minimal changes to work with multiple files or project -

SonarQube SCM TFVC plugin

It requires analysis to be executed from Windows machines with the Team Foundation Server Object Model installed (download for TFS 2013).

This blog post is also having good explaination and sample application -

TFS SDK: Connecting to TFS 2010 & TFS 2012 Programmatically

akjoshi
  • 15,374
  • 13
  • 103
  • 121