Git-tree-sha1 for Artifacts.toml

How is the git-tree-sha1 supposed to be calculated for artifacts?
The instructions in UsingArtifacts don’t seem to produce the correct hash when the file I’m downloading is a “tar.gz” (either when I download the individual files or the “tar.gz” as a single file).

julia> map_hash = create_artifact() do artifact_dir
           download("https://drive.google.com/uc?export=download&id=1Ackbz0YtaliQNCdZmPfj9uWTwhVNBzy8", joinpath(artifact_dir,"map[15].tar.gz"))
           end
SHA1("db4ca5977fa71514f76a3fe0769c1f66ac164c91")

but the value that doesn’t produce an error on Travis under Linux is:

git-tree-sha1 = "017416cd7bb4cf5eb382898a4f6c8a9bf268d848"

As best I can tell, the value of the git-tree-sha1 doesn’t matter for Windows (the system I use) but does matter for Linux (on Travis). The only way I can figure to get the correct hash is to use a random hash value, fail the test on Travis, use the error message on Travis to set the correct value and rerun. Is there a better way?

1 Like

same here. I would like to know too.

You can get the git tree hash of a directory with Pkg.GitTools.tree_hash, but the simplest way to prepare an Artifacts.toml is probably to use ArtifactUtils.jl

1 Like

Super thanks.

Pkg.GitTools.tree_hash takes a HashType first argument, what should I pass there? Thanks.

Not sure what you mean, you can pass the directory as only argument:

julia> bytes2hex(Pkg.GitTools.tree_hash(mktempdir()))
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"

For the curious readers, 4b825dc642cb6eb9a060e54bf8d69288fbee4904 is the git tree hash of a directory without any files beneath it (mind, I didn’t say “empty directory”, it can contain other empty directories)

2 Likes

Thanks.