jacebrowning / gitman

Language-agnostic dependency manager using Git.
https://gitman.readthedocs.io
MIT License
198 stars 32 forks source link

Symbolic links in nested repositories change after running gitman install #299

Closed pritzvac closed 1 year ago

pritzvac commented 1 year ago

Hi, I'm running into an issue when using gitman with nested repositories that appeared in some recent version.

I have a main repository main_repo, where .gitman.yml contains a nested repository nested_repo1 with its own .gitman.yml, linking e.g. to nested_repo2. In both .gitman.yml files, I'm using the links syntax for creating symlinks to the repositories.

When I run gitman install in the main_repo, the symlinks in the nested repository nested_repo1 are changed to incorporate the parent folders, i.e., they change from ../.gitman/nested_repo2/. to ../../../.gitman/nested_repo1/.gitman/nested_repo2/.

After this change, I need to either reset the changes to the links in nested_repo1 or I'd need to commit the changes, which could cause problems when using nested_repo1 on its own.

This started happening after some recent update of gitman. Is this the expected behavior? Can something be modified to make gitman not change the symlinks in nested repositories?

jacebrowning commented 1 year ago

I'm not aware of a change that would cause that. What version are you using? Can you pinpoint which version introduced the new behavior?

pritzvac commented 1 year ago

I'm using version 3.3.2, which seems to be the version that introduced it. When I downgrade to 3.3.1, it doesn't happen. I guess it probably changed with pull request #295

jacebrowning commented 1 year ago

@DavidWatkins do you think your PR could have unintentionally changed this behavior?

DavidWatkins commented 1 year ago

My changes caused this change, but this is because of how find_nested_configs works. To fix this we'd have to change the way find_nested_configs works to instead install nested configs in isolation rather than building up a global config for the top level repository. To get the old functionality you could use --depth 2 when installing in the meantime.

DavidWatkins commented 1 year ago

@pritzvac Do you have an example config I can look at? I am trying to see where it would incorrectly symlink but L400 of gitman/models/config.py uses the current subdirectory as the root and shouldn't be symlinking from the parent directory.

pritzvac commented 1 year ago

Sure, thanks for looking into it. Here's a quick example config I made, linking to subrepository with this config: https://github.com/ctu-mrs/octomap_mapping_planning/blob/master/.gitman.yml

location: .gitman
sources:
  - repo: https://github.com/ctu-mrs/octomap_mapping_planning.git
    name: octomap_mapping_planning
    rev: master
    type: git
    params:
    sparse_paths:
      -
    links:
      - source: ''
        target: ros_packages/octomap_mapping_planning
groups:
  -
default_group: ''

It actually works fine when I call gitman install for the first time, but then it changes the symlinks in the subrepository, when I call it for a second time.

DavidWatkins commented 1 year ago

@pritzvac Can you try my fix in PR #300 and see if it resolves your issue?

pritzvac commented 1 year ago

Yes, the PR fixed my issue, thanks.

jacebrowning commented 1 year ago

Here's the updated release: https://pypi.org/project/gitman/3.3.3/