Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Bindata iff TAGS="bindata" and not up-to-date #10004

Merged
merged 12 commits into from
Jan 27, 2020
Prev Previous commit
Next Next commit
switch to sha1 hash
  • Loading branch information
zeripath committed Jan 26, 2020
commit 4f2ab2bfcca185d10b3809e191eeaf4492e516cb
12 changes: 6 additions & 6 deletions scripts/generate-bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ package main

import (
"bytes"
"crypto/sha1"
"fmt"
"hash/adler32"
"io/ioutil"
"log"
"net/http"
Expand All @@ -32,22 +32,22 @@ func needsUpdate(dir string, filename string) (bool, []byte) {
oldHash = []byte{}
}

adlerHash := adler32.New()
hasher := sha1.New()

err = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we're basically doing make's job. 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. That's what you get when you mix two competing build systems ...

if err != nil {
return err
}
_, _ = adlerHash.Write([]byte(info.Name()))
_, _ = adlerHash.Write([]byte(info.ModTime().String()))
_, _ = adlerHash.Write([]byte(strconv.FormatInt(info.Size(), 16)))
_, _ = hasher.Write([]byte(info.Name()))
_, _ = hasher.Write([]byte(info.ModTime().String()))
_, _ = hasher.Write([]byte(strconv.FormatInt(info.Size(), 16)))
return nil
})
if err != nil {
return true, oldHash
}

newHash := adlerHash.Sum([]byte{})
newHash := hasher.Sum([]byte{})

if bytes.Compare(oldHash, newHash) != 0 {

Expand Down