jacebrowning/gitman

Install cannot mix sources and groups

Erich-McMillan opened this issue · 2 comments

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).

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!

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