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

Install cannot mix sources and groups #238

Closed
Erich-McMillan opened this issue Dec 8, 2020 · 2 comments · Fixed by #239
Closed

Install cannot mix sources and groups #238

Erich-McMillan opened this issue Dec 8, 2020 · 2 comments · Fixed by #239

Comments

@Erich-McMillan
Copy link
Collaborator

Given the yml file:

location: dependencies

sources:
  - name: a
    type: git
    repo: https://project_a
    rev: master
  - name: b
    type: git
    repo: https://project_b
    rev: master

groups:
  - name: group_a_b
    members:
      - a
      - b
  - name: group_b
    members:
      - b

When gitman install a group_b is run only group_b is installed, but expected both 'a' and group_b to be installed.

Believe this issue stems from config.py

def _get_sources_filter(self, *names, sources, skip_default_group):
        """Get filtered sublist of sources."""
        sources_filter = None
        groups_filter = [group for group in self.groups if group.name in list(names)]
        if not skip_default_group:
            groups_filter += self._get_default_group(list(names))
        if groups_filter:
            sources_filter = [
                members for group in groups_filter for members in group.members
            ]
        else:
            sources_filter = list(names) if names else [s.name for s in sources]
        return sources_filter

If a group is provided then only groups can be installed and any individual sources are ignored. This function should support mixing groups and sources.

This brings up an additional issue of groups which contain overlapping sources, where _get_sources_filter does not ensure that sources_filter contains unique values.

When the aforementioned yml is used with the following command gitman install group_a_b group_b will produce the following errors (due to duplicate sources trying to be cloned)

  $ cd /D C:\
  $ cd /D a
  $ git checkout --force master
  $ cd /D b
  $ git checkout --force master

ERROR: No such dependency: b

Propose that _get_sources_filter should allow mixed sources and groups in install, as well as ensuring that the returned sources_filter contains only unique elements (no duplicates).

@jacebrowning
Copy link
Owner

Propose that _get_sources_filter should allow mixed sources and groups in install, as well as ensuring that the returned sources_filter contains only unique elements (no duplicates).

That makes sense to me!

@jacebrowning
Copy link
Owner

The fix for this is available here: https://pypi.org/project/gitman/2.2b5/

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

Successfully merging a pull request may close this issue.

2 participants