Created
January 31, 2012 18:26
-
-
Save teradyne/1712035 to your computer and use it in GitHub Desktop.
Linqpad script for retrieving TFS changesets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Linqpad script for getting changesets based on TFS comments | |
// Run with language: C# statements | |
/* | |
//Use F4 in Linqpad to add these assemblies as references | |
<Query Kind="Statements"> | |
<Reference>X:\TFSLib\Microsoft.TeamFoundation.Client.dll</Reference> | |
<Reference>X:\TFSLib\Microsoft.TeamFoundation.Common.Library.dll</Reference> | |
<Reference>X:\TFSLib\Microsoft.TeamFoundation.VersionControl.Client.dll</Reference> | |
<Namespace>Microsoft.TeamFoundation.Client</Namespace> | |
<Namespace>Microsoft.TeamFoundation.VersionControl.Client</Namespace> | |
</Query> | |
*/ | |
var sprintid = "SPRINT-1234"; //any text string in your tfs checkin comment | |
var tfsUrl = "http://mytfs:8080"; | |
var path = "$/Project/Branch"; | |
int maxChangeSetCount = 100; | |
List<string> filesUpdated = new List<string>(); | |
/* | |
//if using credentials change below | |
string userName = "username"; | |
string password= "password"; | |
string domain = "domain"; | |
NetworkCredential nwCred = new NetworkCredential(userName,password,domain); | |
TeamFoundationServer tfs = new TeamFoundationServer(tfsName, nwCred); | |
*/ | |
TeamFoundationServer tfs = new TeamFoundationServer(tfsUrl); | |
VersionControlServer vcs = tfs.GetService<VersionControlServer>(); | |
IEnumerable changesets = vcs.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, tfs.AuthenticatedUserName, null, LatestVersionSpec.Latest, maxChangeSetCount, true, false); | |
foreach (Changeset cSet in changesets) | |
{ | |
//Console.WriteLine(string.Format("{0} - {1} - {2} - {3}", cSet.ChangesetId, cSet.Committer, cSet.CreationDate, cSet.Comment)); | |
if(cSet.Changes.Length > 0 && cSet.Comment.Contains(sprintid)) | |
{ | |
Console.WriteLine(string.Format("{0} - {1} - {2} - {3}", cSet.ChangesetId, cSet.Committer, cSet.CreationDate, cSet.Comment)); | |
foreach (Change change in cSet.Changes) | |
{ | |
Console.WriteLine( string.Format(" {0} {1}", change.ChangeType, change.Item.ServerItem)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment