3
votes

I´m currently using the following code to find a branch inside a tfs-project by a specified label:

TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(tfsuri));

var vcs = tfs.GetService<VersionControlServer>();

string labelscope = labelscopepath;

var specifiedBranch = vcs.QueryLabels(label, labelscope, null, true);

But this way I only get branches when I know the name of the label. So what I need now is a methode to find all labels inside the specified project and the related branches.

So here is my TFS-structure. The branch "Branch2" has the label "Label1". Now I´d like to list all branches that have a label, including the labelname. In this case only Branch2 would be in this list.

enter image description here

1

1 Answers

3
votes

You could get a list of labels first, then list branches that have a label.

public VersionControlLabel[] QueryLabels(String labelName,
                                         String labelScope,
                                         String owner, 
                                         bool includeItems,
                                         String filterItem,
                                         VersionSpec versionFilterItem)

More details please refer this blog: Displaying the labels on a file, including label comments You could even display Label dialog programatically following this tutorial.