Bug 1798930 - Support .tgz extension in fetch-content r=taskgraph-reviewers,jmaher

Many project use .tgz as a shortcut to .tar.gz. Support that pattern.

Differential Revision: https://phabricator.services.mozilla.com/D161147
This commit is contained in:
serge-sans-paille 2022-11-03 16:22:26 +00:00
Родитель 533f673e9e
Коммит f0f87acd20
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -312,7 +312,7 @@ def open_tar_stream(path: pathlib.Path):
""""""
if path.suffix == ".bz2":
return bz2.open(str(path), "rb")
elif path.suffix == ".gz":
elif path.suffix in (".gz", ".tgz") :
return gzip.open(str(path), "rb")
elif path.suffix == ".xz":
return lzma.open(str(path), "rb")
@ -327,7 +327,7 @@ def open_tar_stream(path: pathlib.Path):
def archive_type(path: pathlib.Path):
"""Attempt to identify a path as an extractable archive."""
if path.suffixes[-2:-1] == [".tar"]:
if path.suffixes[-2:-1] == [".tar"] or path.suffixes[-1:] == [".tgz"]:
return "tar"
elif path.suffix == ".zip":
return "zip"