public void InexactMatch_WithoutTrailingSlash_IsFound() { var visitor = new BranchTreeContainsPathVisitor(@"$/Scratch/Source/Main", false); branch.AcceptVisitor(visitor); Assert.True(visitor.Found); }
public void ExactMatch_WithTrailingSlash_IsNotFound() { var visitor = new BranchTreeContainsPathVisitor(@"$/Scratch/Source/Main/", true); branch.AcceptVisitor(visitor); Assert.False(visitor.Found); }
public static BranchTree GetRootTfsBranchForRemotePath(this ITfsHelper tfs, string remoteTfsPath, bool searchExactPath = true) { var branches = tfs.GetBranches(); var branchTrees = branches.Aggregate(new Dictionary<string, BranchTree>(StringComparer.OrdinalIgnoreCase), (dict, branch) => dict.Tap(d => d.Add(branch.Path, new BranchTree(branch)))); foreach(var branch in branchTrees.Values) { if(!branch.IsRoot) { branchTrees[branch.ParentPath].ChildBranches.Add(branch); } } var roots = branchTrees.Values.Where(b => b.IsRoot); return roots.FirstOrDefault(b => { var visitor = new BranchTreeContainsPathVisitor(remoteTfsPath, searchExactPath); b.AcceptVisitor(visitor); return visitor.Found; }); }