Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for artifacts compressed as '.gz' #73

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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