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

Add group selection to built-in commands #487

Open
mrrosen opened this issue Mar 16, 2021 · 10 comments
Open

Add group selection to built-in commands #487

mrrosen opened this issue Mar 16, 2021 · 10 comments
Labels
Partial imports Incomplete or changing imports are much more complicated than you think

Comments

@mrrosen
Copy link

mrrosen commented Mar 16, 2021

Currently, only west update supports the --group-filter/--gf command line argument, but it would be good if other commands such as west forall and west status also allowed users to run commands on a subset of projects using groups on the commandline without having to list out a bunch of projects in the command line (ie, rather than west status proj1 proj2 proj3 proj4, be able to west status --gf=+mygroup instead).

@mbolivar-nordic
Copy link
Contributor

rather than west status proj1 proj2 proj3 proj4, be able to west status --gf=+mygroup instead

Sorry, but I'm a bit confused about this use case. Those two commands would only produce the same result if all projects are inactive by default. Are you sure this is what you meant?

@mrrosen
Copy link
Author

mrrosen commented Mar 16, 2021

@mbolivar-nordic I might be misunderstanding something as I only recently started looking into groups so Ill give you the concrete thing I was trying to do. In our codebase, we have a manifest repository containing our west.yml which includes a few internal repos as projects and a few external repos (including zephyr) as projects. Something like this:

projects:
  - name: internal1
    revision: some-branch
  - name: internal2
    revision some-branch

  - name: zephyr
    remote: zephyr
    revision: v2.5.0
    import:
      name-whitelist:
      - proj1
      - proj2
  - name: external1
    remote: external-repo
    revision: v1.1.0

Note, there are many more internal and external projects. While all are enabled, I want to do some action (like create a tag) on all of our internal projects repos. I thought adding them all to a group would let me do this using west forall but it doesnt have that functionality right now. I dont necessarily want to disable projects (though thats something we might want to do) across multiple commands, just run a command across a subset of our repos without having to explicitly list them all out.

@mrrosen
Copy link
Author

mrrosen commented Mar 16, 2021

For example, to solve my current problem, I still used west forall but used the fact all of our internal projects share the same remote. It was a bit ugly, thus why I was looking into groups. (Specifically, something like west forall -c "git ls-remote --exit-code internal-remote && git tag MyTag")

@mbolivar-nordic
Copy link
Contributor

OK, so this isn't as much about the group-filter feature as doing some action on all projects with a particular group or groups.

I would prefer to call that option -g / --group. I can add it to the forall command and all the forall-alikes (status, diff, ...).

So you could say west status --group foo and that's the same thing as west status proj1 proj2 ... projN for projects 1 through N with group foo.

Is that what you're asking for?

@mrrosen
Copy link
Author

mrrosen commented Mar 16, 2021

OK, so this isn't as much about the group-filter feature as doing some action on all projects with a particular group or groups.

I would prefer to call that option -g / --group. I can add it to the forall command and all the forall-alikes (status, diff, ...).

So you could say west status --group foo and that's the same thing as west status proj1 proj2 ... projN for projects 1 through N with group foo.

Is that what you're asking for?

Yes, thats exactly what Im looking for

@marc-hb
Copy link
Collaborator

marc-hb commented Mar 16, 2021

OK, so this isn't as much about the group-filter feature as doing some action on all projects with a particular group or groups.
I would prefer to call that option -g / --group. I can add it to the forall command and all the forall-alikes (status, diff, ...).

I don't understand what makes west update different and why its group option should be named differently from west status, diff and all the other commands.

@mbolivar-nordic
Copy link
Contributor

I don't understand what makes west update different and why its group option should be named differently from west status, diff and all the other commands.

Because this is not affecting the group filter at all, it's doing something different. See my original comment in the thread

@marc-hb
Copy link
Collaborator

marc-hb commented Mar 16, 2021

Ah yes of course, I clearly didn't understand the command line --group-filter option. I didn't realize it's not standalone but combined with everything else. I suspect @mrrosen rosen made a similar confusion.

So @mrrosen you're indeed asking for a new, different feature that does not exist yet. Please update the title of this issue.

The next questions that come to mind are then: 1. should west update get the new feature too? 2. Should other commands get the existing --group-filter too? No idea yet.

@mrrosen
Copy link
Author

mrrosen commented Mar 16, 2021

I guess I am since Im not 100% sure I understand the group-filter feature. Im not sure what a better title is as I still want a "group filter" even though it isnt directly using "group-filter"

I guess its that --gr=+gr" would add grp projects only if they are disabled via manifests group filters? But the new --group would be like --gr=-all-other-groups?

@marc-hb
Copy link
Collaborator

marc-hb commented Mar 16, 2021

Like everything in west, --group-filter has excellent and extensive documentation https://docs.zephyrproject.org/latest/guides/west/manifest.html#group-filter

west help update also has a useful clue:

  --group-filter FILTER, --gf FILTER
     proceed as if FILTER was _appended_ to manifest.group-filter; may be given multiple times

Emphasis mine.

The long story short: --group-filter can only alter, not replace the default selection and most repos are (obviously) selected by default. So to west status a small subset you would typically have to exclude a long list of groups on the command line which does not sound like what you're looking for. Group filters also combine all with each other (command line + config + manifests) with some precedence rules which again does not sound like the simpler feature you're after.

Hence @mbolivar-nordic suggesting a new option with a different name and me suggesting you rephrase the title of this issue. "Group selection"?

Hope this helps.

@mrrosen mrrosen changed the title Add group filter to more built-in commands Add group selection to built-in commands Mar 17, 2021
@marc-hb marc-hb added the Partial imports Incomplete or changing imports are much more complicated than you think label Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partial imports Incomplete or changing imports are much more complicated than you think
Projects
None yet
Development

No branches or pull requests

3 participants