Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Fix matching workspace folders (primarily for 'restrictWorkspace') #264

Merged
merged 3 commits into from
Jun 26, 2017

Conversation

jeffyoung
Copy link
Contributor

The existing code works only because TF.exe will return only the workspace mapping information for the folder that is passed in to the command. The TEE CLC returns all workspace mapping information no matter what folder you pass into it. Therefore, when using the CLC, even if the user opens a single folder with tfvc.restrictWorkspace enabled, the first team project (and almost always the wrong one) is chosen. This PR is to ensure we actually get the proper match (the most-specific match) so we can return the proper team project (for both TF.exe (not just because of a bug) and the CLC (because we match the proper folder)).

//With tf.exe, folder and teamProject should match (TEE won't)
if (folder !== teamProject.toLowerCase()) {
for (let i: number = 0; i < mappings.length; i++) {
for (let i: number = 0; i < mappings.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about cloaked paths? Are those excluded somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 Yeah, those are actually excluded by never being returned from the earlier call to getMapping. TF.exe returns a cloaked mapping that ends with ':' and the CLC returns a cloaked mapping that doesn't end with ':'. Both of these fail the if in getMapping. We should talk about how to properly handle cloaked folders (since they aren't today).

openedPath = openedPath.toLowerCase();
workspacePath = workspacePath.toLowerCase();

return openedPath.lastIndexOf(workspacePath, 0) === 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startsWith might read a bit better here.

Copy link
Member

@jpricket jpricket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Some minor comments.

@jeffyoung jeffyoung merged commit b211d1b into master Jun 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants