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
change hash algorithm computation method #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module git.helsinki.tools/helsinki-systems/wp4nix | ||
|
||
go 1.16 | ||
|
||
require github.com/nix-community/go-nix v0.0.0-20231219074122-93cb24a86856 // indirect | ||
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -9,10 +9,13 @@ import ( | |||||||||||||
"log" | ||||||||||||||
"net/http" | ||||||||||||||
"os" | ||||||||||||||
"os/exec" | ||||||||||||||
"regexp" | ||||||||||||||
"strconv" | ||||||||||||||
"strings" | ||||||||||||||
"path/filepath" | ||||||||||||||
"crypto/sha256" | ||||||||||||||
"github.com/nix-community/go-nix/pkg/nar" | ||||||||||||||
"github.com/nix-community/go-nix/pkg/nixbase32" | ||||||||||||||
) | ||||||||||||||
|
||||||||||||||
var DEBUG bool | ||||||||||||||
|
@@ -70,30 +73,21 @@ func writeFile(t string, c map[string]interface{}) { | |||||||||||||
os.Rename(t+"-new.json", t+".json") | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func execCmd(name, dir, file string, args ...string) (string, error) { | ||||||||||||||
log.Printf("%s %s %s", name, file, args) | ||||||||||||||
cmd := exec.Command(file, args...) | ||||||||||||||
cmd.Dir = dir | ||||||||||||||
out, err := cmd.CombinedOutput() | ||||||||||||||
if err != nil { | ||||||||||||||
log.Printf("Failed: %s %s %s %s", err, name, file, args) | ||||||||||||||
} | ||||||||||||||
return strings.TrimSpace(string(out)), err | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
func svnPrefetch(repo *Repository, path string, rev string, rawName string) (string, error) { | ||||||||||||||
h := sha256.New() | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this down to after line 93 (inside the |
||||||||||||||
// people push some weird shit | ||||||||||||||
reg, _ := regexp.Compile("[^a-zA-Z0-9+\\-._?=]+") | ||||||||||||||
fixedName := reg.ReplaceAllString(rawName, "") | ||||||||||||||
dir, _ := ioutil.TempDir("", "wp4nix-prefetch-") | ||||||||||||||
defer os.RemoveAll(dir) | ||||||||||||||
var err error | ||||||||||||||
var resp string | ||||||||||||||
var hashString string | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop this |
||||||||||||||
err = repo.Export(path, rev, dir+"/"+fixedName, nil, nil) | ||||||||||||||
if err == nil { | ||||||||||||||
resp, err = execCmd("Hash", dir, "nix-hash", "--type", "sha256", "--base32", fixedName) | ||||||||||||||
nar.DumpPath(h, filepath.Join(dir, fixedName)) | ||||||||||||||
hashString = nixbase32.EncodeToString(h.Sum(nil)) | ||||||||||||||
Comment on lines
+87
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
return resp, err | ||||||||||||||
return hashString, err | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
// copy every element from every map into the resulting map | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be an
indirect
dependency. Can you please rungo get -u ; go mod tidy
and push the changes? 😊