简体   繁体   English

使用TFS Api查询我的工作区是否包含最新文件

[英]Query if my workspace has the latest files using the TFS Api

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". 我不想做Workspace.Get() ,因为它执行相当于“获取最新”。 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: 我正在Build.I计划中进行此检查有一个像这样的方法:

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? 什么是正确的代码使用?

Use Workspace.Get(LatestVersionSpec.Instance, GetOptions.Preview) then check the GetStatus.NoActionNeeded that is yielded by the Get operation. 使用Workspace.Get(LatestVersionSpec.Instance, GetOptions.Preview)然后检查Get操作产生的GetStatus.NoActionNeeded

So: 所以:

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

    bool hasLatestFiles = result.NoActionNeeded;

    return hasLatestFiles;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM