mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-02-04 03:39:48 +00:00
all: add a test for copyright headers
Fix a few files with no or unusual copyright headers. Manually add copyright headers to the legacy testprotos, which will (probably) never be regenerated. Change-Id: Ifb52fa0eb59bf9d2de40b8df7e581a3c9731c883 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220498 Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
parent
2a63c7aa61
commit
3a18560b88
@ -1,3 +1,7 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2020 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package oneoftest;
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -95,6 +96,10 @@ func Test(t *testing.T) {
|
||||
t.Fatalf("unformatted source files:\n%v", diff)
|
||||
}
|
||||
})
|
||||
t.Run("CopyrightHeaders", func(t *testing.T) {
|
||||
files := strings.Split(strings.TrimSpace(mustRunCommand(t, "git", "ls-files", "*.go", "*.proto")), "\n")
|
||||
mustHaveCopyrightHeader(t, files)
|
||||
})
|
||||
t.Run("CommittedGitChanges", func(t *testing.T) {
|
||||
diff := mustRunCommand(t, "git", "diff", "--no-prefix", "HEAD")
|
||||
if strings.TrimSpace(diff) != "" {
|
||||
@ -362,6 +367,47 @@ func mustHandleFlags(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var copyrightRegex = []*regexp.Regexp{
|
||||
regexp.MustCompile(`^// Copyright \d\d\d\d The Go Authors\. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file\.
|
||||
`),
|
||||
// Generated .pb.go files from main protobuf repo.
|
||||
regexp.MustCompile(`^// Protocol Buffers - Google's data interchange format
|
||||
// Copyright \d\d\d\d Google Inc\. All rights reserved\.
|
||||
`),
|
||||
}
|
||||
|
||||
var noCopyrightHeader = []string{
|
||||
// Missing copyright header upstream.
|
||||
"internal/testprotos/benchmarks/datasets/",
|
||||
}
|
||||
|
||||
func mustHaveCopyrightHeader(t *testing.T, files []string) {
|
||||
var bad []string
|
||||
File:
|
||||
for _, file := range files {
|
||||
for _, prefix := range noCopyrightHeader {
|
||||
if strings.HasPrefix(file, prefix) {
|
||||
continue File
|
||||
}
|
||||
}
|
||||
b, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, re := range copyrightRegex {
|
||||
if loc := re.FindIndex(b); loc != nil && loc[0] == 0 {
|
||||
continue File
|
||||
}
|
||||
}
|
||||
bad = append(bad, file)
|
||||
}
|
||||
if len(bad) > 0 {
|
||||
t.Fatalf("files with missing/bad copyright headers:\n %v", strings.Join(bad, "\n "))
|
||||
}
|
||||
}
|
||||
|
||||
type command struct {
|
||||
Dir string
|
||||
Env []string
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !protolegacy
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build protolegacy
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package pragma provides types that can be embedded into a struct to
|
||||
// statically enforce or prevent certain language properties.
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE.md file.
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package protolegacy is a stub version of the v1 proto package
|
||||
// to satisfy internal/testprotos/legacy dependencies.
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: proto2_20160225_2fc053c5/test.proto
|
||||
// DO NOT EDIT!
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: proto2_20160519_a4ab9ec5/test.proto
|
||||
// DO NOT EDIT!
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto2_20180125_92554152/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto2_20180430_b4deda09/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto2_20180814_aa810b61/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto2_20190205_c823c79e/test.proto
|
||||
|
||||
@ -5,8 +9,9 @@ package proto2_20190205_c823c79e
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "google.golang.org/protobuf/internal/protolegacy"
|
||||
math "math"
|
||||
|
||||
proto "google.golang.org/protobuf/internal/protolegacy"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: proto3_20160225_2fc053c5/test.proto
|
||||
// DO NOT EDIT!
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go.
|
||||
// source: proto3_20160519_a4ab9ec5/test.proto
|
||||
// DO NOT EDIT!
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto3_20180125_92554152/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto3_20180430_b4deda09/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto3_20180814_aa810b61/test.proto
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: proto3_20190205_c823c79e/test.proto
|
||||
|
||||
@ -5,8 +9,9 @@ package proto3_20190205_c823c79e
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "google.golang.org/protobuf/internal/protolegacy"
|
||||
math "math"
|
||||
|
||||
proto "google.golang.org/protobuf/internal/protolegacy"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
Loading…
x
Reference in New Issue
Block a user