Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buf config ls-modules #3081

Merged
merged 6 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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