How to count total lines changed by a specific author in a TFS repository?

1.8k Views Asked by At

I am quite new to this so I would really appreciate your help!!!!

My repository is in TFS and I am using Visual Studio 2015 and SSMS 2016 and my manager asked me to find the "lines changed" per branch for specific author.

Could you please help in how I could achieve that?

1

There are 1 best solutions below

0
On

There is a FactCodeChurn table in the TFS data warehouse that should contain the data you need.

You could use some SQL query statement such as below:

   SELECT TeamProjectProjectNodeName 
          ,checkedinbyname 
          ,SUM([LinesAdded]) AS 
          ,SUM([LinesModified]) AS
          ,SUM([LinesAdded]+[LinesModified]) AS 
          ,CONVERT(VARCHAR(10), MIN(DateTime),120) AS 
          ,CONVERT(VARCHAR(10),MAX(DateTime),120) AS 
      FROM [Tfs_Warehouse].[dbo].[CodeChurnView] WHERE  TeamProjectProjectNodeName='xxx' AND  ChangesetTitle NOT LIKE 'xx'  AND FilenameFileExtension IN('.css','.cs','.aspx','.sql','js','.ascx') AND (LinesDeleted <>0 OR LinesModified<>0 OR FilenameFilePath LIKE '$/XX' AND FilenameFileExtension IN('.sql')) AND NetLinesAdded>=0   GROUP BY TeamProjectProjectNodeName, checkedinbyname 
    ORDER BY DESC

Note: You must have permission to access the Tfs_Warehouse database to execute the above statement.

Take a look at more details about Code Churn tables in warehouse database. Add a related blog including two ways using the TFS API and using the TFS Warehouse Database for your reference: