Skip to content

Commit

Permalink
Add buf config ls-modules (#3081)
Browse files Browse the repository at this point in the history
Fixes #3035.

---------

Co-authored-by: Oliver Sun <73540835+oliversun9@users.noreply.github.com>
Co-authored-by: Oliver Sun <osun@buf.build>
  • Loading branch information
3 people committed Jun 21, 2024
1 parent bbebe8a commit 52a4214
Show file tree
Hide file tree
Showing 22 changed files with 938 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,9 @@ issues:
# This greatly simplifies creation of descriptors, and it's safe enough since
# it's just test code.
path: private/bufpkg/bufimage/source_retention_options_test\.go
- linters:
- paralleltest
path: private/buf/cmd/buf/buf_test.go
# The LsModules tests call chdir and cannot be parallelized.
text: "LsModules"

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Add `buf config ls-modules` command to list configured modules.
- Fix issue where `buf generate` would succeed on missing insertion points and
panic on empty insertion point files.
- Update `buf generate` to allow the use of Editions syntax when doing local code
Expand Down
33 changes: 33 additions & 0 deletions private/buf/bufcli/buf_work_yaml_file.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2020-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package bufcli

import (
"context"

"github.com/bufbuild/buf/private/bufpkg/bufconfig"
)

// GetBufWorkYAMLFileForDirPath gets the buf.work.yaml file for the directory path.
func GetBufWorkYAMLFileForDirPath(
ctx context.Context,
dirPath string,
) (bufconfig.BufWorkYAMLFile, error) {
bucket, err := newOSReadWriteBucketWithSymlinks(dirPath)
if err != nil {
return nil, err
}
return bufconfig.GetBufWorkYAMLFileForPrefix(ctx, bucket, ".")
}
2 changes: 2 additions & 0 deletions private/buf/cmd/buf/buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import (
"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configinit"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlsbreakingrules"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlslintrules"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configlsmodules"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/config/configmigrate"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/convert"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/curl"
Expand Down Expand Up @@ -137,6 +138,7 @@ func NewRootCommand(name string) *appcmd.Command {
configmigrate.NewCommand("migrate", builder),
configlslintrules.NewCommand("ls-lint-rules", builder),
configlsbreakingrules.NewCommand("ls-breaking-rules", builder),
configlsmodules.NewCommand("ls-modules", builder),
},
},
{
Expand Down
Loading

0 comments on commit 52a4214

Please sign in to comment.