Query if my workspace contains recent files using TFS Api

I want to programmatically find out if the workspace has the latest files. I do not want to do Workspace.Get(), because it fulfills the equivalent of "Get the Last." I just want to know if my workspace needs "Get Latest" or not.

I do this check during build. I plan to have a method like this:

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?

+4
source share
1 answer

Use Workspace.Get(LatestVersionSpec.Instance, GetOptions.Preview), then verify GetStatus.NoActionNeededwhich operation is in progress Get.

So:

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

    bool hasLatestFiles = result.NoActionNeeded;

    return hasLatestFiles;
}
+8
source

All Articles