2

我有一个 VS2017 的 Check-In-Policy 扩展(使用 TFS 2017),它检查待处理的签入是否包含与给定正则表达式匹配的文件。
如果匹配文件包含在方法中,CheckedPendingChangesEvaluate返回PolicyFailure以避免签入这些文件。

[Serializable]
public class FileWarningPolicy : PolicyBase
{
   // ...

   public override PolicyFailure[] Evaluate()
   {
        Regex regex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
        if (PendingCheckin.Policies.EvaluationState != PolicyEvaluationState.Evaluated) return new PolicyFailure[0];                
        var matchingFiles = from change in PendingCheckin.PendingChanges.CheckedPendingChanges                                   
                            where change.IsEdit && regex.IsMatch(change.ServerItem)
                            select change;               

        return matchingFiles.Any()
               ? new [] { new PolicyFailure("some error message", this)
               : new PolicyFailure[0];

    }
}

这工作正常。但是,如果我能够简单地“取消选中”这些文件以将它们从当前签入中排除,但不会中止整个签入,那将会更加舒适。

通过该PendingCheckin.PendingChanges属性,我可以访问当前Workspace有很多方法来下载、签入、签出、搁置等存储库项目,但仅从已检查的待处理更改中取消选中/排除它们(仅添加的排除条目.tfignore,这不是我想要的)。

有没有办法做到这一点?

4

0 回答 0