Skip to content

Commit

Permalink
Check if descriptor is nil when filtering unstable packages
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Dec 10, 2020
1 parent 1791ed5 commit 7c0a30a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/buf/bufcheck/bufbreaking/bufbreaking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ func TestRunBreakingFileNoDelete(t *testing.T) {
)
}

func TestRunBreakingFileNoDeleteUnstable(t *testing.T) {
// https://github.com/bufbuild/buf/issues/211
testBreaking(
t,
"breaking_file_no_delete_unstable",
bufanalysistesting.NewFileAnnotationNoLocationOrPath(t, "FILE_NO_DELETE"),
)
}

func TestRunBreakingFileSamePackage(t *testing.T) {
testBreaking(
t,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntax = "proto3";

package a.v1beta1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v1beta1
breaking:
ignore_unstable_packages: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntax = "proto3";

package a.v1beta1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntax = "proto3";

package a.v1beta1;
3 changes: 3 additions & 0 deletions internal/buf/bufcheck/internal/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (r *Runner) newIgnoreFunc(config *Config) IgnoreFunc {
return true
}
if config.IgnoreUnstablePackages {
if descriptor == nil {
return false
}
packageVersion, ok := protoversion.NewPackageVersionForPackage(descriptor.File().Package())
if !ok {
return false
Expand Down

0 comments on commit 7c0a30a

Please sign in to comment.