Skip to content

Conversation

onny
Copy link

@onny onny commented Mar 8, 2024

instead of using os.exec to execute nix-hash, this method uses a native go module for hash computation


go 1.16

require github.com/nix-community/go-nix v0.0.0-20231219074122-93cb24a86856 // indirect
Copy link
Contributor

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 run go get -u ; go mod tidy and push the changes? 😊

}

func svnPrefetch(repo *Repository, path string, rev string, rawName string) (string, error) {
h := sha256.New()
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this down to after line 93 (inside the if err == nil.

defer os.RemoveAll(dir)
var err error
var resp string
var hashString string
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop this

Comment on lines +87 to +88
nar.DumpPath(h, filepath.Join(dir, fixedName))
hashString = nixbase32.EncodeToString(h.Sum(nil))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
nar.DumpPath(h, filepath.Join(dir, fixedName))
hashString = nixbase32.EncodeToString(h.Sum(nil))
if err := nar.DumpPath(h, filepath.Join(dir, fixedName)); err != nil {
return "", fmt.Errorf("failed to dump path: %w", err)
}
return nixbase32.EncodeToString(h.Sum(nil)), nil

hashString = nixbase32.EncodeToString(h.Sum(nil))
}
return resp, err
return hashString, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return hashString, err
return "", err

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants