hashicorp / go-getter

Package for downloading things from a string URL using a variety of protocols.
Mozilla Public License 2.0
1.65k stars 232 forks source link

Git pathspec error when passing depth with ref #225

Open AliAllomani opened 4 years ago

AliAllomani commented 4 years ago

Intermittent Git pathspec error when passing depth with ref, seems the files are being downloaded but it throws the error afterwards

# go-getter "git::https://github.com/hashicorp/packer.git?depth=1" test2
2019/11/28 09:27:15 success!

# du -sh test2
114M    test2

#  go-getter "git::https://github.com/hashicorp/packer.git?depth=1&ref=fix_7677" test4
2019/11/28 09:29:12 Error downloading: error downloading 'https://github.com/hashicorp/packer.git?depth=1&ref=fix_7677': /usr/bin/git exited with 1: error: pathspec 'fix_7677' did not match any file(s) known to git.

# du -sh test4
114M    test4

# go-getter "git::https://github.com/hashicorp/packer.git?ref=fix_7677" test5
2019/11/28 09:30:25 success!

# du -sh test5
138M    test5

# go-getter "git::https://github.com/hashicorp/packer.git?depth=1&ref=hcl2" test6
2019/11/28 09:31:20 Error downloading: error downloading 'https://github.com/hashicorp/packer.git?depth=1&ref=hcl2': /usr/bin/git exited with 1: error: pathspec 'hcl2' did not match any file(s) known to git.

# du -sh test6
114M    test6

# go-getter "git::https://github.com/hashicorp/packer.git?ref=hcl2" test7
2019/11/28 09:32:14 success!

# du -sh test7
136M    test7
mhvelplund commented 3 years ago

It seems random. It works for some repos and not for others. I checked that I could manually get the same ref using git clone --depth 1 --branch v0.0.1 git@github.com:my/module.git and it worked fine ....