List all Protobuf files

To list all files Buf is configured to use:

$ buf ls-files

This will print a list of all Protobuf files managed by Buf per the current configuration's build.roots and build.excludes values.

If you are on commit ${GOOGLEAPIS_COMMIT}, this should result in 2,311 files.

$ buf ls-files | wc -l
2311

The build.roots value specifies the directories to search for Protobuf files, as well as being the root directory that Protobuf imports are expected to derive from. This roughly corresponds to the --proto_path flag in protoc.

The build.excludes value allows you to remove certain directories from being built.

The default value for build.roots is the directory that the buf.yaml file is in, and the default value for build.excludes is empty. We explicitly set these defaults in our buf.yaml file:

version: v1beta1
build:
roots:
- .

You can safely remove this section if:

  • All your Protobuf file imports derive from the root of your repository.
  • There are no excluded directories.

This is the how googleapis is set up. Remove this section to simplify our buf.yaml file for the rest of this tour:

version: v1beta1
lint:
use:
- BASIC
- FILE_LOWER_SNAKE_CASE
except:
- ENUM_NO_ALLOW_ALIAS
- IMPORT_NO_PUBLIC
- PACKAGE_AFFINITY
- PACKAGE_DIRECTORY_MATCH
- PACKAGE_SAME_DIRECTORY
breaking:
use:
- WIRE_JSON