Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query if my workspace has the latest files using the TFS Api

Tags:

c#

.net

tfs-sdk

I want to programmatically find out if a workspace has the latest files. I don't want to do a Workspace.Get(), because that performs the equivalent of "Get Latest". I just want to know if my workspace needs a "Get Latest" or not.

I'm doing this check during a Build.I plan on having a method like so:

public static bool HasLatestFiles(Workspace ws)
{
    bool hasChanges = false;

    /* need correct code to query if ws has latest files */

    return hasChanges;
}

What is the correct code to use?

like image 283
MRothaus Avatar asked Feb 12 '23 17:02

MRothaus


1 Answers

Use Workspace.Get(LatestVersionSpec.Instance, GetOptions.Preview) then check the GetStatus.NoActionNeeded that is yielded by the Get operation.

So:

public static bool HasLatestFiles(Workspace ws)
{
    GetStatus result = ws.Get(LatestVersionSpec.Instance, GetOptions.Preview);

    bool hasLatestFiles = result.NoActionNeeded;

    return hasLatestFiles;
}
like image 117
jessehouwing Avatar answered Feb 14 '23 13:02

jessehouwing