Skip to content

Commit

Permalink
fix: revert update-license.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ronething-bot committed Dec 30, 2024
1 parent c3c9542 commit 9a7bd88
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions build/update-license.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ var (
"crypto/bn256/",
"crypto/bls12381/",
"crypto/ecies/",
"graphql/internal/graphiql/",
"graphql/graphiql.go",
"internal/jsre/deps",
"log/",
Expand Down Expand Up @@ -385,18 +384,20 @@ func writeLicense(info *info) {
if err != nil {
log.Fatalf("error reading %s: %v\n", info.file, err)
}

// check if license header exists
// Construct new file content.
buf := new(bytes.Buffer)
licenseT.Execute(buf, info)
if m := licenseCommentRE.FindIndex(content); m != nil && m[0] == 0 {
fmt.Println("skipping (license exists)", info.file)
buf.Write(content[:m[0]])
buf.Write(content[m[1]:])
} else {
buf.Write(content)
}
// Write it to the file.
if bytes.Equal(content, buf.Bytes()) {
fmt.Println("skipping (no changes)", info.file)
return
}

// only generate new license header if it doesn't exist
buf := new(bytes.Buffer)
licenseT.Execute(buf, info)
buf.Write(content)

fmt.Println("writing", info.ShortLicense(), info.file)
if err := os.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil {
log.Fatalf("error writing %s: %v", info.file, err)
Expand Down

0 comments on commit 9a7bd88

Please sign in to comment.