bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
9.22k stars 279 forks source link

Ability to push a subset of a workspace #3413

Closed doriable closed 1 month ago

doriable commented 1 month ago

Feature

Currently, when calling buf push on a v2 workspace, the intention is to push the entire workspace at once. For example, if a user has the following tree:

.
├── bar
│   └── bar.proto
├── baz
│   └── baz.proto
├── buf.yaml
└── foo
    └── foo.proto

And the buf.yaml is configured as:

version: v2
modules:
  - path: foo
    name: buf.build/<user>/foo
  - path: bar
    name: buf.build/<user>/bar
  - path: baz
    name: buf.build/<user>/baz

And bar.proto imports foo.proto (so the module bar has a dependency on the module foo).

When we call buf push, we push everything, and changes to foo will result in a change to bar, which is expected due to the dependency.

However, there is no way to push a smaller subset of workspaces. The user can call buf push bar, and this would target bar, and also result in a new commit to bar if there are any changes to foo, while ignoring changes to baz, however this behaviour is implicit based on the input path.

If the user has many overlapping workspace roots (e.g. they rely on includes and excludes for their workspace modules), it can be difficult to invoke a push on a subset of their workspace.

Ideally, there is some mechanism that allows them to define which modules they want to push, e.g. something like:

buf push --module buf.build/<user>/bar

Where the dependency on foo will be accounted for (so buf.build/<user>/foo will be pushed if there is a change), but explicitly excludes other non-dependency modules.

doriable commented 1 month ago

After discussions, we will not be pursuing this -- this should be achievable by pushing a specific directory input. If there are shared module roots that make this difficult, the goal is to migrate the workspace configuration such that this is no longer an issue.