diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index 405c8033ae..5a49e9efc8 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -337,6 +337,7 @@ def generated_postscript? def generated_go? return false unless extname == '.go' + return false unless name =~ %r{(?:^|/)[^/]*_generated\..+\.go$} return false unless lines.count > 1 return lines.first(40).any? { |l| l =~ %r{^// Code generated .*} } diff --git a/samples/Go/foo_generated.deepcopy.go b/samples/Go/foo_generated.deepcopy.go new file mode 100644 index 0000000000..2c5ff87482 --- /dev/null +++ b/samples/Go/foo_generated.deepcopy.go @@ -0,0 +1,119 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright The Kubernetes Authors. + +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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Example) DeepCopyInto(out *Example) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Example. +func (in *Example) DeepCopy() *Example { + if in == nil { + return nil + } + out := new(Example) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Example) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExampleList) DeepCopyInto(out *ExampleList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Example, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleList. +func (in *ExampleList) DeepCopy() *ExampleList { + if in == nil { + return nil + } + out := new(ExampleList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ExampleList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExampleSpec) DeepCopyInto(out *ExampleSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleSpec. +func (in *ExampleSpec) DeepCopy() *ExampleSpec { + if in == nil { + return nil + } + out := new(ExampleSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExampleStatus) DeepCopyInto(out *ExampleStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExampleStatus. +func (in *ExampleStatus) DeepCopy() *ExampleStatus { + if in == nil { + return nil + } + out := new(ExampleStatus) + in.DeepCopyInto(out) + return out +} diff --git a/test/test_blob.rb b/test/test_blob.rb index 2ab7f1b02b..95a8cc36c1 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -204,6 +204,7 @@ def test_generated assert sample_blob_memory("Go/api.pb.go").generated? assert sample_blob_memory("Go/embedded.go").generated? assert sample_blob_memory("Go/oapi-codegen.go").generated? + assert sample_blob_memory("Go/foo_generated.deepcopy.go").generated? assert sample_blob_memory("JavaScript/proto.js").generated? assert sample_blob_memory("TypeScript/proto.ts").generated? assert sample_blob_memory("PHP/ProtobufGenerated.php").generated?