bufbuild / buf

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

Remove command package and command.Runner in favor of simpler and stateless execext package #3439

Closed bufdev closed 3 weeks ago

bufdev commented 3 weeks ago

This PR does a longstanding cleanup that has been on my local computer for a while and just needed finishing. This removes the command package in favor of a much-simpler execext package that wraps os/exec with the safety checks we care about.

This gets rid of the stateful command.Runner type, which kept track of the number of running processes it created, and set a hard limit on these, usually based on thread. This was overkill; in places where we perform parallelism, we already use thread.Parallelize, and adding an additional semaphore to block within command had no practical use. The downside was that we had to pass the command.Runner type everywhere, which really cluttered our code, including in some important packages (such as diff) where the fact that we had to pass command.Runner exposed an ugly implementation detail.

This also:

The impact on core should be relatively minimal, as mostly the command package was just used to call command.NewRunner for testing. However, the port is usually just this:

github-actions[bot] commented 3 weeks ago

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedNov 1, 2024, 5:44 PM