Skip to content

feat: add project groups and --group filter - #56

Open
temp wants to merge 1 commit into
daFish:mainfrom
temp:feat/project-groups
Open

feat: add project groups and --group filter#56
temp wants to merge 1 commit into
daFish:mainfrom
temp:feat/project-groups

Conversation

@temp

@temp temp commented Sep 2, 2026

Copy link
Copy Markdown

What

Groups are named sets of projects defined in the config file. They can be targeted with --group instead of spelling out directories every time.

projects:
  api: git@github.com:org/api.git
  web: git@github.com:org/web.git
  libs/shared: git@github.com:org/shared.git

groups:
  frontend: [web]
  backend: [api, libs/shared]

commands:
  migrate:
    cmd: npm run migrate
    groups: [backend]
gogo exec --group backend "npm test"
gogo exec --group backend,frontend "npm test"   # union of both groups
gogo git status --group backend                 # available on every filter command
gogo run migrate                                # uses the groups from the command definition

JSON works the same way. Like the other filters, --group is also available as a persistent root flag, and it combines with --include-only / --exclude-only / the patterns via AND. A --group flag on the command line replaces the groups from a command definition.

Implementation

  • internal/config: MetaConfig.Groups, CommandConfig.Groups, ResolveGroups (union, deduplicated, sorted), GetGroupNames / GetGroup; merge rule for overlays (the overlay wins per group name); RemoveProject keeps groups consistent.
  • internal/filter: new first filter stage Options.GroupOnly — exact path match, no basename match, since group members are config keys.
  • internal/cli: --group flag in addFilterFlags and in the root persistent flags; resolveFilterOptionsWithConfig resolves group names against the merged config and only reads the config when --group is used.

Design decision: references are resolved lazily

Group and command cross-references are not validated while reading a config. Otherwise a group referencing a project that lives in an overlay which is not loaded would break every unrelated command — that runs against the whole point of overlays. Instead:

  • Validate only checks a single file structurally (name not empty, at least one member).
  • ResolveGroups reports bad references when a group is actually used: unknown group "nope". Available groups: backend, frontend.
  • gogo validate checks all references against the merged config (config.ValidateReferences), which also surfaces errors that used to be swallowed silently.

Tests

go test -race ./... passes, go vet is clean. New tests in internal/config/config_test.go, internal/filter/filter_test.go, internal/cli/group_test.go and internal/cli/validate_test.go: resolving single and multiple groups, dedupe, unknown group, intersection with include-only / exclude-only, groups from JSON and YAML, overlay merge, write/read round-trip, command groups, RemoveProject cleanup, lazy reference resolution, and the gogo validate report.

Also verified end-to-end with the built binary against a real project, including a group defined in an overlay and a broken reference. make lint did not run locally — golangci-lint is not installed here; CI covers it.

🤖 Generated with Claude Code

Groups are named sets of projects defined in the config file and can be
targeted with --group instead of spelling out directories every time:

    groups:
      backend: [api, libs/shared]

    gogo exec --group backend "npm test"

Multiple groups are combined as a union; --group intersects with the
existing filters. Predefined commands can name their groups via the new
"groups" key, which a --group flag on the command line overrides.

Group and command cross-references are resolved lazily rather than while
reading a config, so a group that references a project living in an
overlay that is not loaded does not break unrelated commands. Using such
a group reports the problem, and gogo validate checks all references
against the merged config.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant