Skip to content

Commit

Permalink
Added support for artifacts compressed as '.gz' (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
meruiden authored Aug 28, 2024
1 parent a4c80f2 commit ccee0ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
15 changes: 15 additions & 0 deletions lib/sources/artifact/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub enum ArtifactFormat {
Zip,
Tar,
TarGz,
Gz,
}

impl ArtifactFormat {
Expand All @@ -19,6 +20,7 @@ impl ArtifactFormat {
Self::Zip => "zip",
Self::Tar => "tar",
Self::TarGz => "tar.gz",
Self::Gz => "gz",
}
}

Expand All @@ -33,6 +35,7 @@ impl ArtifactFormat {
{
Some(Self::TarGz)
}
[.., ext] if ext.eq_ignore_ascii_case("gz") => Some(Self::Gz),
_ => None,
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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));
}
}
1 change: 1 addition & 0 deletions lib/sources/artifact/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down

0 comments on commit ccee0ca

Please sign in to comment.