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

[Feature request / searching for solution] Import recursively #282

Open
rsarrazin2 opened this issue Jan 24, 2025 · 3 comments
Open

[Feature request / searching for solution] Import recursively #282

rsarrazin2 opened this issue Jan 24, 2025 · 3 comments

Comments

@rsarrazin2
Copy link

Also using vcs for the same reasons mentioned in #221 (git submodules being too error-prone, especially for non-git-affine developers), I still see a downside to vcs, which is the (apparent) inability to import / pull recursively into the pointed-to repositories.

The --recursive is obviously not an option since it involves git submodules - which we want to avoid at all costs. Since there can be multiple .repos files in the imported repos - and we may not want to recursively import all of them - the manifest file could contain an optional dependencies (or any other good name) list field that points to the .repos files inside the repo that vcs then shall use when importing recursively.

For the time being, and since vcs doesn't allow for custom fields, I plan to write a wrapper around vcs that imports all new dependencies.repos files found after an import. Here some pseudo-code:

vcs import < $initial_repos_file

repos_files = find_new_repos_files("dependencies.repos")

while(repos_files.not_empty()):
  for(file in repos_files):
    vcs import < $file

  repos_files = find_new_repos_files("dependencies.repos")

My question here: Is there a more straightforward way to import recursively with the current vcs version? I may have missed some very simple way.

Thanks in advance for the answers.

@rsarrazin2
Copy link
Author

Quick addition: It looks like vcs does accept (and obviously ignore) additional fields in the YAML .repos file so that I could store the "subdependencies" in the .repos file. Be like:

repositories:
  other/repo2:
    type: git
    url: /home/rolands/workspace/_test/test_vcs/repo2/
    version: 2ea2ca5138d042eca88fdbd119bd2661f8de5213
    subdependencies: [test.repos, other_dependency.repos]

The wrapper is then a lot easier as I just need to take the location (other/repo2), join with the subdependency (test.repos) and import from there by calling the wrapper recursively. The corner case of possible infinite recursion can be mitigated by having a configurable maximum import depth to prevent it.

Still, if there's an easier solution working with the current vcs version, my question holds.

@andry81
Copy link

andry81 commented Jan 25, 2025

repositories:
other/repo2:
type: git
url: /home/rolands/workspace/_test/test_vcs/repo2/
version: 2ea2ca5138d042eca88fdbd119bd2661f8de5213
subdependencies: [test.repos, other_dependency.repos]

Why not to make a conditional import?

repositories:
  other/repo2:
    type: git
    url: /home/rolands/workspace/_test/test_vcs/repo2/
    version: 2ea2ca5138d042eca88fdbd119bd2661f8de5213
    if:
      expr: (( TESTS )) # a bash shell condition
      then:
        - import: test.repos # relative to this file
        - import:
          - other/test.repos # relative to this file
          - ./_externals/myproj1/.repos # conditional import from an external repository of the `other/repo2` repository
          - $PROJECT_ROOT/_externals/myproj2/.repos # conditional import from an external repository of an arbitrary root repository
          - $UNEXISTED/_externals/myproj3/.repos # invalid import, `$UNEXISTED` is empty
    if:
      expr: (( OTHER_DEPS ))
      then:
        - import: other/other_dependency.repos
PROJECT_ROOT=~/myreporoot
TESTS=1 OTHER_DEPS=1 vcs import < .repos

@jfrascon
Copy link

jfrascon commented Jan 27, 2025

The corner case of possible infinite recursion can be mitigated by having a configurable maximum import depth to prevent it.

Or, before downloading the remote repository, you could check whether the local path (e.g., <your_workspace>/src/other/ros2) already exists in your filesystem. If the folder exists, you could throw an error or warning indicating that the repository has already been downloaded and take appropriate action accordingly.

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

No branches or pull requests

3 participants