John Rocha
John Rocha

Reputation: 1705

How to query TFS history for a particular user from the CLI

I'm attempting to find all of my TFS commits using the CLI commmand tf history (yes I'm limited to the CLI).

I see that TFS has a /user option but it doesn't appear to work. For example if I just look without the filter I'll get a hit such as

Changeset User              Date       Comment
--------- ----------------- ---------- ------------------------------
10945     Rocha, John R     9/4/2015   LO-4838 Update label # to 47

However when I try the command:

tf history . /noprompt /recursive /stopafter:10 /user:"Rocha, John R"

it results in

Option user requires exactly one value.

What am I missing?

Upvotes: 0

Views: 350

Answers (1)

DaveShaw
DaveShaw

Reputation: 52818

The comma in the username is causing an issue because it thinks that there is more than one username specified.

It might work if you try the username instead of the display name - I can't test because mine are the same.

You can find it by running:

net user "Rocha, John R" /domain

Hopefully, there's a Username returned that doesn't have a "," in it.

Looking at the source code for the TFS Command Line Parser, I cannot see a workaround, the User option is declared as MultipleValues style, and the value parser for MutlipleValues splits on , with no escape sequence I can see - the tf history command then validates that only one value can be returned from the user option.

Here's the code from the Parser:

case Options.Style.MultipleValues:
{
    int num;
    while ((num = argument.IndexOf(',', startIndex)) != -1)
    {
        if (num - startIndex == 0)
        {
            throw new Command.ArgumentListException(ClientResources.ExtraCommaInOption(invokedAs));
        }
        option.Values.Add(argument.Substring(startIndex, num - startIndex));
        startIndex = num + 1;
    }
    if (argument.Substring(startIndex).Length == 0)
    {
        throw new Command.ArgumentListException(ClientResources.ExtraCommaInOption(invokedAs));
    }
    option.Values.Add(argument.Substring(startIndex));
    return;
}

Upvotes: 1

Related Questions