# Git-tree-sha1 for Artifacts.toml

**URL:** <https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879>\
**Category:** General Usage\
**Created:** [July 29, 2020, 1:21pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879 "2020-07-29T13:21:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NicholasWMRitchie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nicholaswmritchie/32/22449_2.png) [@NicholasWMRitchie](https://discourse.julialang.org/u/NicholasWMRitchie)\
**Post date:** [July 29, 2020, 1:21pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/1 "2020-07-29T13:21:28Z")

</div>

How is the `git-tree-sha1` supposed to be calculated for artifacts?  
The instructions in [UsingArtifacts](https://julialang.github.io/Pkg.jl/v1/artifacts/#Using-Artifacts-1) 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
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?

---

<div class="post-metadata">

**Author:** ![arhik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arhik/32/8991_2.png) [@arhik](https://discourse.julialang.org/u/arhik)\
**Post date:** [November 30, 2020, 2:35pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/2 "2020-11-30T14:35:00Z")

</div>

same here. I would like to know too.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 30, 2020, 2:53pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/3 "2020-11-30T14:53:42Z")

</div>

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`](https://github.com/simeonschaub/ArtifactUtils.jl)

---

<div class="post-metadata">

**Author:** ![arhik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arhik/32/8991_2.png) [@arhik](https://discourse.julialang.org/u/arhik)\
**Post date:** [December 1, 2020, 7:09am UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/4 "2020-12-01T07:09:05Z")

</div>

Super thanks.

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 28, 2022, 10:27pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/5 "2022-09-28T22:27:20Z")

</div>

> [@giordano](#):
>
> You can get the git tree hash of a directory with `Pkg.GitTools.tree_hash`

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

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [September 28, 2022, 10:37pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/6 "2022-09-28T22:37:51Z")

</div>

> [@e3c6](#):
>
> `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
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)

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [September 28, 2022, 10:53pm UTC](https://discourse.julialang.org/t/git-tree-sha1-for-artifacts-toml/43879/7 "2022-09-28T22:53:54Z")

</div>

Thanks.
