Skip to content

Have a buf source migrate command #4412

@doriable

Description

@doriable

Feature

Similar to buf config migrate, which migrates/upgrades the buf.{yaml,gen.yaml} config files, it would be nice to have a command in buf source which is able to migrate/upgrade the syntax/edition of the proto source.

Example UX

buf source migrate <input> [--syntax, --diff]
  • The input default is . if not specified, and is otherwise a source input (dir/on-disk modules/workspace or protofileref), same behaviour as other commands we have.
  • The user can optionally specify a --syntax, e.g. --syntax=proto3 or --syntax=2024 (for editions 2024). If no syntax is specified, we'll use the latest implemented edition of the compiler the CLI version current depends on (https://github.com/bufbuild/protocompile/blob/aa1a63ac3dac8c2eb5bbebf21d6a8b5c0b8f8e5b/experimental/ast/syntax/editions.go#L24)
  • If the source is already on the specified syntax and/or the source is already on the latest syntax, it's a no-op on the source file
  • --diff produces only a diff output, if any, and does not write in-place. The default behaviour writes in-place. This is the same UX as buf config migrate (although I am open to deviating from that, just wanted to use an existing frame of reference for consistency)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions