Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Multi Workspace workaround to the PathTooLong issue #1478

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

patricecalvehoc
Copy link

[x] run and verify that existing tests pass. Add some new units tests, if needed.
[x] update the documentation, if needed.
[ ] update the release notes file NOT done...

There are situations where the workaround of using a very short path for a custom workspace is not enough.

The solution implemented leverages a TFVC workspace's ability to have multiple Working Folders. A new git tfs clone argument was created --MultipleWorkingFoldersConfigFilePath that allows the user to specify a json file containing an array of folder mappings that are passed along to the creation of the Workspace. These mappings are "SourceControlFolder" and "LocalFolder".

  • SourceControlFolder: TFVC path ($/...) triggering the Path too long
  • LocalFolder: a local folder (shorter the better) where the items will be mapped to.

I've updated the doc/Set-custom-workspace.md with the instructions and an example/scenario

Co-authored-by: Philippe Miossec <pmiossec@gmail.com>
@pmiossec
Copy link
Member

pmiossec commented Mar 4, 2024

FYI, no need to open a new PR when you do changes. You just have to push the new commits (with a force push if needed when exceptionally you rewrote the git history)

@pmiossec
Copy link
Member

pmiossec commented Mar 5, 2024

I have noticed also some other little refactoring to do quicker to do than explained. Unfortunately, I can't push them 😭

image

The "Maintainers are allowed to edit this pull request" option is checked, which is good.
But you have created the PR from the master branch which is, FYI, a bad practice (for multiple reasons).
When you want to contribute to a project, always create a feature branch, with a good naming and create the PR from there.

So, could you please fetch the commits I pushed to my fork ( https://github.com/pmiossec/git-tfs/tree/patricecalvehoc/master ), review it and if that's OK for you, squash everything (again 😉 ) in one commit and force push to your branch?

I think that technically the code is OK.
@siprbaum do you want to review it also?

The only question that I have in my mind that could prevent to merge this PR (i.e. reject it) is:

Why the "short workspace" and/or long path solution is not enough? and so is this proposition really improving the situation?

I don't have a case to test it and confirm if it really works but in another end, if you have migrated a code base using it, I think we could be pretty confident that it is working 🤣 .

I'm ready to accept it as another way to work around the long path issue (if "short workspace is not enough) as the code seems easy to maintain and also this provide a full "git-tfs" solution to the problem (user don't have to change a system setting that could have other side effects otherwise Microsoft would have enabled it by default since a long time -- right!?! Because that's really a pain this limitation when you encounter the problem--)

@siprbaum point of view?

@patricecalvehoc
Copy link
Author

I need a good course on "github" :( Sorry for the back and forth. I will make the changes you ask.

In our TFVC, we have an item that is 264 characters long.

If I want to retire the old TFS server, but keep/protect each project's source code history, git-tfs is a great tool. The other solution would be to fast-forward the upgrades from TFS to a recent ADOServer version, then use cloud migration utility, but it's a path I didn't want to try if avoidable.

@@ -42,7 +42,9 @@ Another better solution if you faced this problem is to use a custom workspace d

You could set the workspace directory when cloning the tfs repository using the `--workspace` option :

git tfs clone http://server/tfs $/Project/trunk project --workspace="c:\ws"
```DOS
Copy link
Member

Choose a reason for hiding this comment

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

AFAIK there is no DOS in the supported list of languages.
https://github.com/github-linguist/linguist/blob/master/lib/linguist/languages.yml

Maybe change this to sh ?

Copy link
Author

Choose a reason for hiding this comment

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

Comment on lines -180 to +187
return Path.Combine(_localDirectory, path);
var localPath = Path.Combine(_localDirectory, path);

if (System.IO.File.Exists(localPath))
{
return localPath;
}

return this._workspace.GetLocalItemForServerItem($"{Remote.TfsRepositoryPath}/{path}");
Copy link
Member

Choose a reason for hiding this comment

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

I haven't thought much about this, so take my comments with a grain of salt.

With the above change, we now we have different behavior if a file exists or not at a specific path,
which makes me nervous. Should we not always return this._workspace.GetLocalItemForServerItem($"{Remote.TfsRepositoryPath}/{path}")

Copy link
Author

Choose a reason for hiding this comment

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

Very good point... Good catch

Example:
$/SomeTeamProject/Foo/FileXYZ.txt
$/SomeTeamProject/FolderSuperLong/Foo/FileXYZ.txt

if git clone $/SomeTeamProject --workspace w:\ --MultipleWorkingFoldersConfigFilePath c:\mapping.json

and mapping.json:

[
  {"$/SomeTeamProject/FolderSuperLong" : "x:\1"}
]

Then, there will be

W:\Foo\FileXYZ.txt ($/SomeTeamProject/Foo/FileXYZ.txt)
X:\1\Foo\FileXYX.txt ($/SomeTeamProject/FolderSuperLong/Foo/FileXYZ.txt)

They are two different files.

With the code I proposed, when looking for $/SomeTeamProject/FolderSuperLong/Foo/FileXYZ.txt, the first check will be using var localPath = Path.Combine(_localDirectory, path);, and will find one under W:\Foo\FileXYZ.txt but will be the wrong one.

@siprbaum
Copy link
Member

siprbaum commented Mar 5, 2024

@pmiossec I am currently lacking time to do any OSS work at all since quite a while now, that is why I am lacking behind :-(

I did a very quick glance over the PR, it seems isolated so I don't see a reason (besides complete lack of tests)
why not to integrate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants