fabioz/mu-repo

Symlinks with mu register --recursive

bodograumann opened this issue · 7 comments

When calling mu register --recursive symlinks are followed. That is ok afaic. The problem is, that now the linked repository is listed two times. Once under its original path and once under the symlink.

For example:

projects/
	proj1/
		node_modules/
			proj3 → ../../proj3
	proj2/
	proj3/

The above structure will we detected as .mu_repo:

repo=proj1
repo=proj1/node_modules/proj3
repo=proj2
repo=proj3

Thanks for the report... Would you like to provide a pull request to fix it?

The related code lives at: https://github.com/fabioz/mu-repo/blob/master/mu_repo/action_register.py

I would like to do that. Feel free to ping me if I forget about it.
One thing I need to know first though: Looking at the code it seems you don’t really follow symlinks. It is only by luck that one symlink pointing directly at a git repository works. Is it ok, if I change that behavior, so that the search descends through all symlinks (and normalizes the resulting paths)?

Yes, that should be ok (just make sure you detect cycles in that case).

I hope this covers all the cycling cases.

Thank you very much for the pull request... do you think you can create a test for this?

It should be straightforward -- you can follow the same steps from https://github.com/fabioz/mu-repo/blob/master/mu_repo/tests/test_checkout.py, and checking if the .mu_repo contents are correct after the register command.

Yes. I already thought about that, but wasn’t sure how to do the setup. The example you gave should be enough to start with, I think.

Here you go :-)