From 3bbd451fd1cb65a82ac07c9cb494a895f299bc8e Mon Sep 17 00:00:00 2001 From: Corne Date: Tue, 27 Aug 2024 21:21:08 +0200 Subject: [PATCH 1/2] add support for .gz files --- lib/sources/artifact/format.rs | 15 +++++++++++++++ lib/sources/artifact/mod.rs | 1 + 2 files changed, 16 insertions(+) diff --git a/lib/sources/artifact/format.rs b/lib/sources/artifact/format.rs index 2c7b789..67c2686 100644 --- a/lib/sources/artifact/format.rs +++ b/lib/sources/artifact/format.rs @@ -10,6 +10,7 @@ pub enum ArtifactFormat { Zip, Tar, TarGz, + Gz, } impl ArtifactFormat { @@ -19,6 +20,7 @@ impl ArtifactFormat { Self::Zip => "zip", Self::Tar => "tar", Self::TarGz => "tar.gz", + Self::Gz => "gz", } } @@ -33,6 +35,7 @@ impl ArtifactFormat { { Some(Self::TarGz) } + [.., ext] if ext.eq_ignore_ascii_case("gz") => Some(Self::Gz), _ => None, } } @@ -78,6 +81,8 @@ mod tests { assert_eq!(format_from_str("file.zip"), Some(ArtifactFormat::Zip)); assert_eq!(format_from_str("file.tar"), Some(ArtifactFormat::Tar)); assert_eq!(format_from_str("file.tar.gz"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.tgz"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.gz"), Some(ArtifactFormat::Gz)); assert_eq!( format_from_str("file.with.many.extensions.tar.gz.zip"), Some(ArtifactFormat::Zip) @@ -117,6 +122,10 @@ mod tests { format_from_str("sentry-cli-linux-i686-2.32.1.tgz"), Some(ArtifactFormat::TarGz) ); + assert_eq!( + format_from_str("lefthook_1.7.14_Windows_x86_64.gz"), + Some(ArtifactFormat::Gz) + ); } #[test] @@ -130,5 +139,11 @@ mod tests { assert_eq!(format_from_str("file.tar.gz"), Some(ArtifactFormat::TarGz)); assert_eq!(format_from_str("file.TAR.GZ"), Some(ArtifactFormat::TarGz)); assert_eq!(format_from_str("file.Tar.Gz"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.tgz"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.TGZ"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.Tgz"), Some(ArtifactFormat::TarGz)); + assert_eq!(format_from_str("file.gz"), Some(ArtifactFormat::Gz)); + assert_eq!(format_from_str("file.GZ"), Some(ArtifactFormat::Gz)); + assert_eq!(format_from_str("file.Gz"), Some(ArtifactFormat::Gz)); } } diff --git a/lib/sources/artifact/mod.rs b/lib/sources/artifact/mod.rs index fa62b5f..65bdeca 100644 --- a/lib/sources/artifact/mod.rs +++ b/lib/sources/artifact/mod.rs @@ -84,6 +84,7 @@ impl Artifact { let tar = decompress_gzip(&contents).await?; extract_tar_file(&tar, &file_name).await } + ArtifactFormat::Gz => decompress_gzip(&contents).await.map(Some), }; // Make sure we got back the file we need ... From 9a86950eebdc23cb3345af7b45be64236e9fa569 Mon Sep 17 00:00:00 2001 From: Corne Date: Wed, 28 Aug 2024 08:27:46 +0200 Subject: [PATCH 2/2] update changelog to include #73 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c70b9bd..1a57983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added support for artifacts compressed as '.gz' ([#73]) + +[#73]: https://github.com/rojo-rbx/rokit/pull/73 + ### Changed - Changed instructions in `self-install` command on Windows to tell the user to restart their _computer_ instead of their _terminal_ ([#71])