fix: revert update-license.go
This commit is contained in:
parent
c3c95428ef
commit
9a7bd8810b
|
@ -70,7 +70,6 @@ var (
|
||||||
"crypto/bn256/",
|
"crypto/bn256/",
|
||||||
"crypto/bls12381/",
|
"crypto/bls12381/",
|
||||||
"crypto/ecies/",
|
"crypto/ecies/",
|
||||||
"graphql/internal/graphiql/",
|
|
||||||
"graphql/graphiql.go",
|
"graphql/graphiql.go",
|
||||||
"internal/jsre/deps",
|
"internal/jsre/deps",
|
||||||
"log/",
|
"log/",
|
||||||
|
@ -385,18 +384,20 @@ func writeLicense(info *info) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error reading %s: %v\n", info.file, err)
|
log.Fatalf("error reading %s: %v\n", info.file, err)
|
||||||
}
|
}
|
||||||
|
// Construct new file content.
|
||||||
// check if license header exists
|
|
||||||
if m := licenseCommentRE.FindIndex(content); m != nil && m[0] == 0 {
|
|
||||||
fmt.Println("skipping (license exists)", info.file)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// only generate new license header if it doesn't exist
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
licenseT.Execute(buf, info)
|
licenseT.Execute(buf, info)
|
||||||
|
if m := licenseCommentRE.FindIndex(content); m != nil && m[0] == 0 {
|
||||||
|
buf.Write(content[:m[0]])
|
||||||
|
buf.Write(content[m[1]:])
|
||||||
|
} else {
|
||||||
buf.Write(content)
|
buf.Write(content)
|
||||||
|
}
|
||||||
|
// Write it to the file.
|
||||||
|
if bytes.Equal(content, buf.Bytes()) {
|
||||||
|
fmt.Println("skipping (no changes)", info.file)
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Println("writing", info.ShortLicense(), info.file)
|
fmt.Println("writing", info.ShortLicense(), info.file)
|
||||||
if err := os.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil {
|
if err := os.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil {
|
||||||
log.Fatalf("error writing %s: %v", info.file, err)
|
log.Fatalf("error writing %s: %v", info.file, err)
|
||||||
|
|
Loading…
Reference in New Issue