22
votes

How do you export history from TFS 2010 that includes the user, date and the complete comment (not truncated)?

For example, in Team Explorer: right-click team member name > show check-in history. This will bring up the user's check-in history, but the comments are truncated.

5

5 Answers

20
votes

You have 3 options here:

  1. Parse output from the tf.exe history command.
  2. Write code against the TFS client object model.
  3. Write a query directly against the TFS database.

Number 1 is probably the easiest so I'll start with that. You can read the documentation for the tf history command here. In order to get the comment non-truncated you will need to use the /format:detailed option. If you want all of the history, try something like this:

tf history $/ /r /format:detailed /noprompt

If you are looking for all of the changesets for a given user, try this:

tf history $/ /r /format:detailed /user: /noprompt

That will produce a fair amount of text output that you would need to parse to be able to put it into excel. Give that a shot and if you are interested in options 2 or 3 let me know and I can give you more details.

9
votes

The easiest way is to connect to the TFSWharehouse from excel, then pull the data from the source control history in a excel sheet. This is really simple and very powerful.

You'll find useful info here: http://www.woodwardweb.com/vsts/getting_started.html

Edit:

Using the TFS API to enumerate the changesets when you don't have access to SSAS (e.g. tfspreview.com for instance):

TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, true);
tpp.ShowDialog();

var tpc = tpp.SelectedTeamProjectCollection;

VersionControlServer versionControl = tpc.GetService<VersionControlServer>();

var tp = versionControl.GetTeamProject("MyTeamProject");
var path = tp.ServerItem;

var q = versionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, new ChangesetVersionSpec(1), VersionSpec.Latest, Int32.MaxValue, false, true, false, false);

foreach (Changeset cs in q)
{
    var user = cs.Owner;
    var comment = cs.Comment;
    var date = cs.CreationDate;

    Debug.WriteLine(string.Format("[{3}] Date: {0}, User: {1}, Comment {2}", date, user, comment, cs.ChangesetId));
}
2
votes

You can also use TFS Rest API like this:-

https://{accountName}.visualstudio.com/{project}/_apis/tfvc/changesets?
searchCriteria.author={userName}&$top=100

This will generate a JSON, you can upload it to any online site like https://json-csv.com/ and get the CSV.

2
votes

A simpler rendition than the above for visualstudio.com

https://{accountName}.visualstudio.com/{project}/_apis/tfvc/changesets?$top=10000&maxCommentLength=2000

You need the max comment length to stop it from truncating. The above tool didn't work, but this one does: http://www.convertcsv.com/json-to-csv.htm

0
votes

This is really not an automated export however,thought of sharing.

For VS2015 What I found easier was following(around 20 changesets)

  1. Opened the branch in VS2015
  2. Right Click=>View History=>All changesets Visible
  3. Clicked on each changeset ==>Right Click=>Changeset Details
  4. Team Explorer-Changeset Details Opens on Right.
  5. Select one of the file.
  6. Using Shift and Down arrow you can copy the entire list of files in that particular changeset.
  7. Paste to an Excel Sheet(it copied the path of files with the file names)

Did above for all the changesets and got my complete list.